Add tests for string methods that support UTF-8 already.

This commit is contained in:
Bob Nystrom
2015-01-22 15:28:54 -08:00
parent c5e67953b8
commit a92e58c804
6 changed files with 22 additions and 1 deletions

View File

@ -4,3 +4,7 @@ IO.print("something".contains("meth")) // expect: true
IO.print("something".contains("some")) // expect: true
IO.print("something".contains("ing")) // expect: true
IO.print("something".contains("math")) // expect: false
// Non-ASCII.
IO.print("søméthîng".contains("méth")) // expect: true
IO.print("søméthîng".contains("meth")) // expect: false

View File

@ -2,4 +2,8 @@ IO.print("abcd".endsWith("cd")) // expect: true
IO.print("abcd".endsWith("abcde")) // expect: false
IO.print("abcd".endsWith("abcd")) // expect: true
IO.print("abcd".endsWith("f")) // expect: false
IO.print("abcd".endsWith("")) // expect: true
IO.print("abcd".endsWith("")) // expect: true
// Non-ASCII.
IO.print("søméthîng".endsWith("thîng")) // expect: true
IO.print("søméthîng".endsWith("thing")) // expect: false

View File

@ -17,3 +17,7 @@ IO.print("" != "abcd") // expect: true
// Not equal to other types.
IO.print("1" != 1) // expect: true
IO.print("true" != true) // expect: true
// Non-ASCII.
IO.print("vålue" == "value") // expect: false
IO.print("vålue" == "vålue") // expect: true

View File

@ -2,3 +2,8 @@ IO.print("abcd".indexOf("cd")) // expect: 2
IO.print("abcd".indexOf("a")) // expect: 0
IO.print("abcd".indexOf("abcde")) // expect: -1
IO.print("abab".indexOf("ab")) // expect: 0
// Non-ASCII. Note that it returns byte indices, not code points.
IO.print("søméஃthîng".indexOf("e")) // expect: -1
IO.print("søméஃthîng".indexOf("m")) // expect: 3
IO.print("søméஃthîng".indexOf("thî")) // expect: 9

View File

@ -3,3 +3,7 @@ IO.print("abcd".startsWith("a")) // expect: true
IO.print("abcd".startsWith("abcd")) // expect: true
IO.print("abcd".startsWith("abcde")) // expect: false
IO.print("abcd".startsWith("")) // expect: true
// Non-ASCII.
IO.print("søméthîng".startsWith("sømé")) // expect: true
IO.print("søméthîng".startsWith("some")) // expect: false