diff options
author | daurnimator <quae@daurnimator.com> | 2018-04-20 21:16:24 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2018-04-20 21:16:24 +1000 |
commit | a260f381d30e036b39078fee0295e539067c10a3 (patch) | |
tree | 4f3b2ecb264ec8dd29cac74d23223d15d297eb8e /test/test-suite/pm-gsub.lua | |
parent | fe9b43374c2e8dc28df0ce460aefaf50b933aaa7 (diff) | |
parent | 9f5d4d35de0b88334bba7c11a9e960a19ee0740b (diff) | |
download | fengari-a260f381d30e036b39078fee0295e539067c10a3.tar.gz fengari-a260f381d30e036b39078fee0295e539067c10a3.tar.bz2 fengari-a260f381d30e036b39078fee0295e539067c10a3.zip |
Merge branch 'test-with-jest'
Diffstat (limited to 'test/test-suite/pm-gsub.lua')
-rw-r--r-- | test/test-suite/pm-gsub.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/test-suite/pm-gsub.lua b/test/test-suite/pm-gsub.lua new file mode 100644 index 0000000..d873cce --- /dev/null +++ b/test/test-suite/pm-gsub.lua @@ -0,0 +1,17 @@ +assert(string.gsub('ülo ülo', 'ü', 'x') == 'xlo xlo') +assert(string.gsub('alo úlo ', ' +$', '') == 'alo úlo') -- trim +assert(string.gsub(' alo alo ', '^%s*(.-)%s*$', '%1') == 'alo alo') -- double trim +assert(string.gsub('alo alo \n 123\n ', '%s+', ' ') == 'alo alo 123 ') +t = "abç d" +a, b = string.gsub(t, '(.)', '%1@') +assert('@'..a == string.gsub(t, '', '@') and b == 5) +a, b = string.gsub('abçd', '(.)', '%0@', 2) +assert(a == 'a@b@çd' and b == 2) +assert(string.gsub('alo alo', '()[al]', '%1') == '12o 56o') +assert(string.gsub("abc=xyz", "(%w*)(%p)(%w+)", "%3%2%1-%0") == + "xyz=abc-abc=xyz") +assert(string.gsub("abc", "%w", "%1%0") == "aabbcc") +assert(string.gsub("abc", "%w+", "%0%1") == "abcabc") +assert(string.gsub('áéí', '$', '\0óú') == 'áéí\0óú') +assert(string.gsub('', '^', 'r') == 'r') +assert(string.gsub('', '$', 'r') == 'r') |