aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/skylark/testdata
diff options
context:
space:
mode:
authorGravatar laurentlb <laurentlb@google.com>2018-03-21 15:39:11 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-21 15:40:11 -0700
commit76972e2e069436d222153c66618e10f9e26db331 (patch)
tree4b2225e23a1f4b7966440f6919205995581afc95 /src/test/skylark/testdata
parent9eea0f9a98c6bec344284bfecc7c91c9d8dd7715 (diff)
Introduce string.elem() method.
RELNOTES[NEW]: Strings have a new .elems() method, that provides an iterator on the characters of the string. PiperOrigin-RevId: 189980269
Diffstat (limited to 'src/test/skylark/testdata')
-rw-r--r--src/test/skylark/testdata/string_elems.sky13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/skylark/testdata/string_elems.sky b/src/test/skylark/testdata/string_elems.sky
new file mode 100644
index 0000000000..3dbe724995
--- /dev/null
+++ b/src/test/skylark/testdata/string_elems.sky
@@ -0,0 +1,13 @@
+# string.elems
+assert_eq(list("abcd".elems()), ["a", "b", "c", "d"])
+
+assert_eq(len("aaa".elems()), 3)
+
+def test_iter():
+ i = 0
+ for c in "abcd".elems():
+ assert_eq(c, "abcd"[i])
+ i += 1
+ assert_eq(i, 4)
+
+test_iter()