From 83514648f2e4e63dcd039e976f3b5d47552e0383 Mon Sep 17 00:00:00 2001 From: Laurent Le Brun Date: Thu, 2 Mar 2017 14:12:53 +0000 Subject: Improve error message for the 'in' operator. In particular, display the type that was passed as argument. -- PiperOrigin-RevId: 148995695 MOS_MIGRATED_REVID=148995695 --- .../com/google/devtools/build/lib/syntax/EvaluationTest.java | 7 +++---- .../google/devtools/build/lib/syntax/SkylarkEvaluationTest.java | 9 --------- 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'src/test/java/com/google/devtools/build/lib/syntax') diff --git a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java index f217591bb8..0f2a2cbb17 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java @@ -673,10 +673,9 @@ public class EvaluationTest extends EvaluationTestCase { @Test public void testInFail() throws Exception { newTest() - .testIfExactError( - "in operator only works on strings if the left operand is also a string", "1 in '123'") - .testIfExactError( - "in operator only works on lists, tuples, sets, dicts and strings", "'a' in 1"); + .testIfErrorContains( + "'in ' requires string as left operand, not 'int'", "1 in '123'") + .testIfErrorContains("'int' is not iterable. in operator only works on ", "'a' in 1"); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java index 6353c1270e..a72f5e5a91 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java @@ -1241,15 +1241,6 @@ public class SkylarkEvaluationTest extends EvaluationTest { @Test public void testListConcatenation() throws Exception {} - @Override - @Test - public void testInFail() throws Exception { - new SkylarkTest().testIfExactError( - "in operator only works on strings if the left operand is also a string", "1 in '123'"); - new SkylarkTest().testIfExactError( - "in operator only works on lists, tuples, sets, dicts and strings", "'a' in 1"); - } - @Override @Test public void testListComprehensionsMultipleVariablesFail() throws Exception { -- cgit v1.2.3