diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-05-23 15:45:13 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-05-23 16:20:50 +1000 |
commit | 02ae800eb611f489e43b9924c8d7fc18e534a726 (patch) | |
tree | ab46a6afced07c8fbaf951dc257551c2df1401a2 /tests | |
parent | d6606a992d859230bb8a989ec96603407f6e79fe (diff) | |
download | jimtcl-02ae800eb611f489e43b9924c8d7fc18e534a726.zip jimtcl-02ae800eb611f489e43b9924c8d7fc18e534a726.tar.gz jimtcl-02ae800eb611f489e43b9924c8d7fc18e534a726.tar.bz2 |
Fix some minor parsing bugs
And add additional tests
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/parse.test | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/tests/parse.test b/tests/parse.test index 55fbe7d..dc09798 100644 --- a/tests/parse.test +++ b/tests/parse.test @@ -33,5 +33,108 @@ test parse-1.8 "Dict sugar" { set x $a([set y b]) } 2 +test parse-1.9 "Backslash newline" { + set x 123;\ + set y 456 + list $x $y +} {123 456} + +test parse-1.10 "Backslash newline in quotes" { + set x "abc\ +def" +} "abc def" + +test parse-1.11 "Backslash newline in quotes after var" { + set y 1 + set x "abc$y\ +def" +} "abc1 def" + +test parse-1.12 "Backslash newline in quotes after var" { + set y 1 + set x "abc$y\ +def" +} "abc1 def" + +test parse-1.13 "Newline in quotes" { + set y 1 + set x "abc +def" +} "abc\ndef" + +test parse-1.14 "Newline in quotes after var" { + set y 1 + set x "abc$y +def" +} "abc1\ndef" + +test parse-1.15 "Space in quotes" { + set y 1 + set x "abc def" +} "abc def" + +test parse-1.16 "Space in quotes after var" { + set y 1 + set x "abc${y} def" +} "abc1 def" + +test parse-1.17 "Command and var in quotes" { + set y 1 + set x "[set z 2][set y]" +} 21 + +test parse-1.18 "Command and var in bare context" { + set y 1 + set x [set z 2][set y] +} 21 + +test parse-1.19 "Lone dollar sign in quotes" { + set y 1 + set x "6$[set y]" +} 6\$1 + +test parse-1.20 "Command and var in bare context" { + set y 1 + set x 6$[set y] +} 6\$1 + +test parse-1.21 "Comment" { + set y 1 +# A comment one a line + set x [set y] ;# comment after semicolon +} 1 + +test parse-1.22 "# char" { + set y 1 + append y # + set x "[set y]#" +} {1##} + +test parse-1.23 "newline in command" { + set y 1 + set z 2 + set x [incr y + incr z] + list $x $y $z +} {3 2 3} + +test parse-1.24 "semicolon in command" { + set x [list a; list b c; list d e f] +} {d e f} + +# Note that Tcl complains about the missing brace here +# while Jim ignores it +test parse-1.25 "missing brace in var" jim { + unset -nocomplain a + set a 3 + set brace \{ + set x [subst \$${brace}a] +} 3 + +test parse-1.26 "newline in braced var" { + set "a\nb" var1 + set x ${a +b} +} var1 testreport |