diff options
author | hlaaftana <10591326+hlaaftana@users.noreply.github.com> | 2020-04-28 20:44:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-28 19:44:52 +0200 |
commit | cd9af6b8040bc72985d457e5169e18ded7c107d6 (patch) | |
tree | 62807f310d4483b9e14db0ae5a639ff3c1b029a9 /tests/stdlib | |
parent | d5ed4fba3e9225e687d916fd4129e3c61550e193 (diff) | |
download | Nim-cd9af6b8040bc72985d457e5169e18ded7c107d6.tar.gz |
StringStream & more stdlib modules support for JS/NimScript (#14095)
* StringStream & more stdlib modules support for JS/NimScript * change back pegs test in line with #14134
Diffstat (limited to 'tests/stdlib')
-rw-r--r-- | tests/stdlib/thtmlparser.nim | 4 | ||||
-rw-r--r-- | tests/stdlib/tparscfg.nim | 61 | ||||
-rw-r--r-- | tests/stdlib/tparsesql.nim | 3 | ||||
-rw-r--r-- | tests/stdlib/tpegs.nim | 1 | ||||
-rw-r--r-- | tests/stdlib/tstdlib_various.nim | 25 |
5 files changed, 53 insertions, 41 deletions
diff --git a/tests/stdlib/thtmlparser.nim b/tests/stdlib/thtmlparser.nim index ccf2f6202..e7dcd50d5 100644 --- a/tests/stdlib/thtmlparser.nim +++ b/tests/stdlib/thtmlparser.nim @@ -1,6 +1,6 @@ discard """ + targets: "c js" output: ''' -@[] true https://example.com/test?format=jpg&name=orig## https://example.com/test?format=jpg&name=orig##text @@ -40,7 +40,7 @@ block t2813: """ var errors: seq[string] = @[] let tree = parseHtml(newStringStream(html), "test.html", errors) - echo errors # Errors: </thead> expected,... + doAssert errors.len == 0 # Errors: </thead> expected,... var len = tree.findAll("tr").len # len = 6 var rows: seq[XmlNode] = @[] diff --git a/tests/stdlib/tparscfg.nim b/tests/stdlib/tparscfg.nim index fc735f3eb..ddb9b02b7 100644 --- a/tests/stdlib/tparscfg.nim +++ b/tests/stdlib/tparscfg.nim @@ -1,29 +1,5 @@ discard """ -output: ''' -utf-8 -on -hello -lihf8515 -10214028 -lihaifeng@wxm.com -=== -charset=utf-8 -[Package] -name=hello ---threads:on -[Author] -name=lhf -qq=10214028 -email="lihaifeng@wxm.com" -=== -charset=utf-8 -[Package] -name=hello ---threads:on -[Author] -name=lihf8515 -qq=10214028 -''' + targets: "c js" """ import parsecfg, streams @@ -46,24 +22,35 @@ var pname = dict2.getSectionValue("Package","name") var name = dict2.getSectionValue("Author","name") var qq = dict2.getSectionValue("Author","qq") var email = dict2.getSectionValue("Author","email") -echo charset -echo threads -echo pname -echo name -echo qq -echo email - -echo "===" +doAssert charset == "utf-8" +doAssert threads == "on" +doAssert pname == "hello" +doAssert name == "lihf8515" +doAssert qq == "10214028" +doAssert email == "lihaifeng@wxm.com" ## Modifying a configuration file. var dict3 = loadConfig(newStringStream(ss.data)) dict3.setSectionKey("Author","name","lhf") -write(stdout, $dict3) - -echo "===" +doAssert $dict3 == """charset=utf-8 +[Package] +name=hello +--threads:on +[Author] +name=lhf +qq=10214028 +email="lihaifeng@wxm.com" +""" ## Deleting a section key in a configuration file. var dict4 = loadConfig(newStringStream(ss.data)) dict4.delSectionKey("Author","email") -write(stdout, $dict4) +doAssert $dict4 == """charset=utf-8 +[Package] +name=hello +--threads:on +[Author] +name=lihf8515 +qq=10214028 +""" diff --git a/tests/stdlib/tparsesql.nim b/tests/stdlib/tparsesql.nim index 8cf8fa848..ba9e601a1 100644 --- a/tests/stdlib/tparsesql.nim +++ b/tests/stdlib/tparsesql.nim @@ -1,3 +1,6 @@ +discard """ + targets: "c js" +""" import parsesql doAssert $parseSQL("SELECT foo FROM table;") == "select foo from table;" diff --git a/tests/stdlib/tpegs.nim b/tests/stdlib/tpegs.nim index b07442dcb..2990a44a5 100644 --- a/tests/stdlib/tpegs.nim +++ b/tests/stdlib/tpegs.nim @@ -1,4 +1,5 @@ discard """ + targets: "c js" output: ''' PEG AST traversal output ------------------------ diff --git a/tests/stdlib/tstdlib_various.nim b/tests/stdlib/tstdlib_various.nim index d1723df78..6856fcd79 100644 --- a/tests/stdlib/tstdlib_various.nim +++ b/tests/stdlib/tstdlib_various.nim @@ -38,8 +38,8 @@ true """ import - critbits, sets, strutils, tables, random, algorithm, re, ropes, segfaults, - lists, parsesql, streams, os, htmlgen, xmltree, strtabs + critbits, cstrutils, sets, strutils, tables, random, algorithm, re, ropes, + segfaults, lists, parsesql, streams, os, htmlgen, xmltree, strtabs block tcritbits: @@ -245,3 +245,24 @@ block txmltree: ]) ]) doAssert(y.innerText == "foobar") + + +block tcstrutils: + let s = cstring "abcdef" + doAssert s.startsWith("a") + doAssert not s.startsWith("b") + doAssert s.endsWith("f") + doAssert not s.endsWith("a") + + let a = cstring "abracadabra" + doAssert a.startsWith("abra") + doAssert not a.startsWith("bra") + doAssert a.endsWith("abra") + doAssert not a.endsWith("dab") + + doAssert cmpIgnoreCase(cstring "FooBar", "foobar") == 0 + doAssert cmpIgnoreCase(cstring "bar", "Foo") < 0 + doAssert cmpIgnoreCase(cstring "Foo5", "foo4") > 0 + + doAssert cmpIgnoreStyle(cstring "foo_bar", "FooBar") == 0 + doAssert cmpIgnoreStyle(cstring "foo_bar_5", "FooBar4") > 0 |