diff options
author | 2016-07-20 20:16:33 +0000 | |
---|---|---|
committer | 2016-07-21 20:34:19 +0000 | |
commit | 9c4629dafc3aafc10f952824efd448700ad3363e (patch) | |
tree | e6926eb4b2f882ec84a3fb09ee678031c5e04d08 /src/test/java/com/google | |
parent | 2e1dbd79ae73753a7a14ddc991fa0b374bbf8605 (diff) |
RELNOTES: Add global hash() function for strings (only)
--
MOS_MIGRATED_REVID=127979748
Diffstat (limited to 'src/test/java/com/google')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java b/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java index a9f82d597e..b93ce6e6b5 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java @@ -1484,6 +1484,20 @@ public class MethodLibraryTest extends EvaluationTestCase { } @Test + public void testHash() throws Exception { + // This test is too strong, in that it tests whether the hash value of the string follows + // Java's specific algorithm for Strings. If our hash implementation is changed then this + // test will have to be modified. + new SkylarkTest() + .testStatement("hash('skylark')", "skylark".hashCode()) + .testStatement("hash('google')", "google".hashCode()) + .testIfErrorContains( + "Method hash(value: string) is not applicable for arguments (NoneType): " + + "'value' is NoneType, but should be string", + "hash(None)"); + } + + @Test public void testRange() throws Exception { new BothModesTest() .testStatement("str(range(5))", "[0, 1, 2, 3, 4]") |