mirror of
https://github.com/janet-lang/janet
synced 2025-10-18 09:17:40 +00:00
Fix error in string.replace-all
This commit is contained in:
@@ -34,6 +34,8 @@
|
||||
(assert (<= 1.0 2.0 3.0 3.0 4.0 5.0 6.0) "less than or equal to reals")
|
||||
(assert (>= 6 5 4 4 3 2 1) "greater than or equal to integers")
|
||||
(assert (>= 6.0 5.0 4.0 4.0 3.0 2.0 1.0) "greater than or equal to reals")
|
||||
(assert (= 7 (% 20 13)) "modulo 1")
|
||||
(assert (= -7 (% -20 13)) "modulo 2")
|
||||
|
||||
(assert (order< nil false true
|
||||
(fiber.new (fn [x] x))
|
||||
@@ -60,6 +62,8 @@
|
||||
(assert (not nil) "nil literal")
|
||||
(assert (= 7 (| 3 4)) "bit or")
|
||||
(assert (= 0 (& 3 4)) "bit and")
|
||||
(assert (= 0xFF (^ 0x0F 0xF0)) "bit xor")
|
||||
(assert (= 0xF0 (^ 0xFF 0x0F)) "bit xor 2")
|
||||
|
||||
# Set global variables to prevent some possible compiler optimizations that defeat point of the test
|
||||
(var zero 0)
|
||||
|
@@ -52,5 +52,25 @@
|
||||
(def X1 100)
|
||||
(assert (= X1 100) "X1 as symbol")
|
||||
|
||||
# String functions
|
||||
(assert (= 3 (string.find "abc" " abcdefghijklmnop")) "string.find 1")
|
||||
(assert (= nil (string.find "" "")) "string.find 2")
|
||||
(assert (= 0 (string.find "A" "A")) "string.find 3")
|
||||
(assert (= (string.replace "X" "." "XXX...XXX...XXX") ".XX...XXX...XXX") "string.replace 1")
|
||||
(assert (= (string.replace-all "X" "." "XXX...XXX...XXX") "...............") "string.replace-all 1")
|
||||
(assert (= (string.replace-all "XX" "." "XXX...XXX...XXX") ".X....X....X") "string.replace-all 2")
|
||||
(assert (= (string.ascii-lower "ABCabc&^%!@:;.") "abcabc&^%!@:;.") "string.ascii-lower")
|
||||
(assert (= (string.ascii-upper "ABCabc&^%!@:;.") "ABCABC&^%!@:;.") "string.ascii-lower")
|
||||
(assert (= (string.reverse "") "") "string.reverse 1")
|
||||
(assert (= (string.reverse "a") "a") "string.reverse 2")
|
||||
(assert (= (string.reverse "abc") "cba") "string.reverse 3")
|
||||
(assert (= (string.reverse "abcd") "dcba") "string.reverse 4")
|
||||
(assert (= (string.join @["one" "two" "three"] ",") "one,two,three") "string.join 1")
|
||||
(assert (= (string.join @["one" "two" "three"] ", ") "one, two, three") "string.join 2")
|
||||
(assert (= (string.join @["one" "two" "three"]) "onetwothree") "string.join 3")
|
||||
(assert (= (string.join @[] "hi") "") "string.join 4")
|
||||
(assert (deep= (string.split "," "one,two,three") @["one" "two" "three"]) "string.split 1")
|
||||
(assert (deep= (string.split "," "onetwothree") @["onetwothree"]) "string.split 2")
|
||||
|
||||
(end-suite)
|
||||
|
||||
|
Reference in New Issue
Block a user