diff options
author | Ori Bernstein <ori@eigenstate.org> | 2015-04-13 00:45:52 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2015-04-13 00:45:52 -0700 |
commit | 5665ec50835d983ecfd73e669864ab75a65f4461 (patch) | |
tree | 784a9e1f194744234d0049d048329719f23c1048 /libregex/test | |
parent | 7c4f9de24d02cf599d4ef1c0e38e5112b0873e97 (diff) | |
download | mc-5665ec50835d983ecfd73e669864ab75a65f4461.tar.gz |
Move code to subdir in preparation for merging with mc.
Diffstat (limited to 'libregex/test')
-rw-r--r-- | libregex/test/Makefile | 20 | ||||
-rw-r--r-- | libregex/test/basic.myr | 31 | ||||
-rw-r--r-- | libregex/test/boundaries.myr | 17 | ||||
-rw-r--r-- | libregex/test/capture.myr | 9 | ||||
-rw-r--r-- | libregex/test/class.myr | 67 | ||||
-rw-r--r-- | libregex/test/data/basic-expected | 20 | ||||
-rw-r--r-- | libregex/test/data/boundaries-expected | 28 | ||||
-rw-r--r-- | libregex/test/data/capture-expected | 18 | ||||
-rw-r--r-- | libregex/test/data/class-expected | 56 | ||||
-rw-r--r-- | libregex/test/data/failmatch-expected | 1 | ||||
-rw-r--r-- | libregex/test/data/negclass-expected | 54 | ||||
-rw-r--r-- | libregex/test/data/unicode-expected | 13 | ||||
-rw-r--r-- | libregex/test/failmatch.myr | 8 | ||||
-rw-r--r-- | libregex/test/negclass.myr | 72 | ||||
-rwxr-xr-x | libregex/test/runtest.sh | 124 | ||||
-rw-r--r-- | libregex/test/testmatch.myr | 34 | ||||
-rw-r--r-- | libregex/test/tests | 29 | ||||
-rw-r--r-- | libregex/test/unicode.myr | 13 |
18 files changed, 614 insertions, 0 deletions
diff --git a/libregex/test/Makefile b/libregex/test/Makefile new file mode 100644 index 0000000..e559327 --- /dev/null +++ b/libregex/test/Makefile @@ -0,0 +1,20 @@ +# don't build anything for 'all' +all: + $(MAKE) -C .. + +check: + ./runtest.sh + +.PHONY: % +%: + ./runtest.sh $@ + +.PHONY: clean +clean: + rm -f testmatch.use testmatch.o + @for i in `awk '/^[A-Z]/{print $$2}' tests`; do \ + echo rm -f $$i; \ + rm -f $$i; \ + done + +install: diff --git a/libregex/test/basic.myr b/libregex/test/basic.myr new file mode 100644 index 0000000..92816fa --- /dev/null +++ b/libregex/test/basic.myr @@ -0,0 +1,31 @@ +use std + +use "testmatch.use" + +const main = { + var s : byte[:] + + s = std.strjoin([ + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + ][:], "") + testmatch(".*bc", "Abc") + testmatch("(a*)*", "a") + testmatch("(aa|aab?)*", s) + /* greedy matches */ + testmatch("(<.*>).*", "<a foo> blah <bar>") + testmatch("(<.+>).*", "<a foo> blah <bar>") + /* reluctant matches */ + testmatch("(<.*?>).*", "<a foo> blah <bar>") + testmatch("(<.+?>).*", "<a foo> blah <bar>") +} diff --git a/libregex/test/boundaries.myr b/libregex/test/boundaries.myr new file mode 100644 index 0000000..03157e4 --- /dev/null +++ b/libregex/test/boundaries.myr @@ -0,0 +1,17 @@ +use "testmatch.use" + +const main = { + /* expected matches */ + testmatch("\\<([a-z]*)\\>", "abcdef") /* whole word */ + testmatch(".*(\\<.*\\>).*", "!m!") /* single char word in midstring */ + testmatch(".*(\\<.*\\>).*", "!m") /* single char word at end of string */ + testmatch(".*(\\<.*\\>).*", "m!") /* single char word at start of string */ + testmatch(".*(\\<.*\\>).*", "!@#!!matches!!%!") /* word in midstring */ + testmatch(".*(\\<.*\\>).*", "matches!!%!") /* word at start of string */ + testmatch(".*(\\<.*\\>).*", "!@#!!matches") /* word at end of string */ + testmatch(".*(\\<.*\\>).*", "!@#!!matches!!%!foo") /* matches last word in string */ + testmatch(".*(\\<.*\\>).*", "123") /* numbers are also word bounds */ + + /* nonmatches */ + testmatch("\\<([a-z]*)\\>foo", "abcdefoo") /* word boundary needed in midstring */ +} diff --git a/libregex/test/capture.myr b/libregex/test/capture.myr new file mode 100644 index 0000000..30d9a68 --- /dev/null +++ b/libregex/test/capture.myr @@ -0,0 +1,9 @@ +use "testmatch.use" + +const main = { + testmatch("A(.*)", "Abc") + testmatch("A(.*)e", "Abcde") + testmatch("(a|b)+", "abab") + testmatch("A(b(.*)d)e", "Abcde") + testmatch("(a?)(a*)(a?)", "aaaa") +} diff --git a/libregex/test/class.myr b/libregex/test/class.myr new file mode 100644 index 0000000..d40571c --- /dev/null +++ b/libregex/test/class.myr @@ -0,0 +1,67 @@ +use std + +use "testmatch.use" + +const main = { + asciiclass() + set() + /* + unicodeclass() + negasciiclass() + negasciirange() + negset() + */ +} + +const asciiclass = { + /* \d success */ + testmatch("\\d", "1") + testmatch("\\d\\d", "13") + testmatch("\\d+", "13688") + /* \d fail */ + testmatch("\\d", "x") + testmatch("\\d\\d", "x3") + testmatch("\\d+", "1368f") + + /* \x success */ + testmatch("\\x", "a") + testmatch("\\x\\x", "1F") + testmatch("\\x+", "13b8cDEf") + /* \x fail */ + testmatch("\\x", "Z") + testmatch("\\x\\x", "fg") + testmatch("\\x+", "13b8cg") + + /* \s success */ + testmatch("\\s", " ") + testmatch("\\s\\s", "\t\n") + testmatch("\\s+", "\t\n\r \t") + /* \s fail */ + testmatch("\\s", "a") + testmatch("\\s\\s", "i\n") + testmatch("\\s+", "\t\n\r.\t") + + /* word success */ + testmatch("\\w+", "abcABC0123_") + /* word fail */ + testmatch("\\w+", "abcABC0123_.") + + /* \h success */ + testmatch("\\h", " ") + testmatch("\\h\\h", "\t ") + testmatch("\\h+", "\t \t ") + /* \h fail */ + testmatch("\\h", "\n") + testmatch("\\h\\h", "\t\r") + testmatch("\\h+", "\t \t.") +} + +const set = { + /* ranges */ + testmatch("[a-z]*", "abcd") + testmatch("[a-zA-Z]*", "abCD") + testmatch("[a-zA-Z0-9_]*", "_abCD018") + + testmatch("[abc]*", "abba") + testmatch("[a-zABC]*", "abBa") +} diff --git a/libregex/test/data/basic-expected b/libregex/test/data/basic-expected new file mode 100644 index 0000000..411872f --- /dev/null +++ b/libregex/test/data/basic-expected @@ -0,0 +1,20 @@ +Matched Abc via .*bc : 1 + match 0: Abc +Matched a via (a*)* : 2 + match 0: a + match 1: a +Matched aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa via (aa|aab?)* : 2 + match 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + match 1: aa +Matched <a foo> blah <bar> via (<.*>).* : 2 + match 0: <a foo> blah <bar> + match 1: <a foo> blah <bar> +Matched <a foo> blah <bar> via (<.+>).* : 2 + match 0: <a foo> blah <bar> + match 1: <a foo> blah <bar> +Matched <a foo> blah <bar> via (<.*?>).* : 2 + match 0: <a foo> blah <bar> + match 1: <a foo> +Matched <a foo> blah <bar> via (<.+?>).* : 2 + match 0: <a foo> blah <bar> + match 1: <a foo> diff --git a/libregex/test/data/boundaries-expected b/libregex/test/data/boundaries-expected new file mode 100644 index 0000000..3706af6 --- /dev/null +++ b/libregex/test/data/boundaries-expected @@ -0,0 +1,28 @@ +Matched abcdef via \<([a-z]*)\> : 2 + match 0: abcdef + match 1: abcdef +Matched !m! via .*(\<.*\>).* : 2 + match 0: !m! + match 1: m +Matched !m via .*(\<.*\>).* : 2 + match 0: !m + match 1: m +Matched m! via .*(\<.*\>).* : 2 + match 0: m! + match 1: m +Matched !@#!!matches!!%! via .*(\<.*\>).* : 2 + match 0: !@#!!matches!!%! + match 1: matches +Matched matches!!%! via .*(\<.*\>).* : 2 + match 0: matches!!%! + match 1: matches +Matched !@#!!matches via .*(\<.*\>).* : 2 + match 0: !@#!!matches + match 1: matches +Matched !@#!!matches!!%!foo via .*(\<.*\>).* : 2 + match 0: !@#!!matches!!%!foo + match 1: foo +Matched 123 via .*(\<.*\>).* : 2 + match 0: 123 + match 1: 123 +No match of abcdefoo via \<([a-z]*)\>foo diff --git a/libregex/test/data/capture-expected b/libregex/test/data/capture-expected new file mode 100644 index 0000000..c4ac17d --- /dev/null +++ b/libregex/test/data/capture-expected @@ -0,0 +1,18 @@ +Matched Abc via A(.*) : 2 + match 0: Abc + match 1: bc +Matched Abcde via A(.*)e : 2 + match 0: Abcde + match 1: bcd +Matched abab via (a|b)+ : 2 + match 0: abab + match 1: b +Matched Abcde via A(b(.*)d)e : 3 + match 0: Abcde + match 1: c + match 2: bcd +Matched aaaa via (a?)(a*)(a?) : 4 + match 0: aaaa + match 1: a + match 2: aaa + match 3: diff --git a/libregex/test/data/class-expected b/libregex/test/data/class-expected new file mode 100644 index 0000000..571719a --- /dev/null +++ b/libregex/test/data/class-expected @@ -0,0 +1,56 @@ +Matched 1 via \d : 1 + match 0: 1 +Matched 13 via \d\d : 1 + match 0: 13 +Matched 13688 via \d+ : 1 + match 0: 13688 +No match of x via \d +No match of x3 via \d\d +No match of 1368f via \d+ +Matched a via \x : 1 + match 0: a +Matched 1F via \x\x : 1 + match 0: 1F +Matched 13b8cDEf via \x+ : 1 + match 0: 13b8cDEf +No match of Z via \x +No match of fg via \x\x +No match of 13b8cg via \x+ +Matched via \s : 1 + match 0: +Matched + via \s\s : 1 + match 0: + +Matched +
via \s+ : 1 + match 0: +
+No match of a via \s +No match of i + via \s\s +No match of +
. via \s+ +Matched abcABC0123_ via \w+ : 1 + match 0: abcABC0123_ +No match of abcABC0123_. via \w+ +Matched via \h : 1 + match 0: +Matched via \h\h : 1 + match 0: +Matched via \h+ : 1 + match 0: +No match of + via \h +No match of
via \h\h +No match of . via \h+ +Matched abcd via [a-z]* : 1 + match 0: abcd +Matched abCD via [a-zA-Z]* : 1 + match 0: abCD +Matched _abCD018 via [a-zA-Z0-9_]* : 1 + match 0: _abCD018 +Matched abba via [abc]* : 1 + match 0: abba +Matched abBa via [a-zABC]* : 1 + match 0: abBa diff --git a/libregex/test/data/failmatch-expected b/libregex/test/data/failmatch-expected new file mode 100644 index 0000000..364bc05 --- /dev/null +++ b/libregex/test/data/failmatch-expected @@ -0,0 +1 @@ +No match of Abc via .*bcd diff --git a/libregex/test/data/negclass-expected b/libregex/test/data/negclass-expected new file mode 100644 index 0000000..84b77d5 --- /dev/null +++ b/libregex/test/data/negclass-expected @@ -0,0 +1,54 @@ +Matched x via \D : 1 + match 0: x +Matched xa!#^cs via \D+ : 1 + match 0: xa!#^cs +No match of 0 via \D +No match of 9 via \D +No match of a35x via \D+ +No match of 13688 via \D+ +Matched Z via \X : 1 + match 0: Z +Matched gg via \X\X : 1 + match 0: gg +No match of a via \X +No match of zz13b8cDEf via \X+ +Matched a via \S : 1 + match 0: a +Matched i% via \S\S : 1 + match 0: i% +Matched alskd690!#!! via \S+ : 1 + match 0: alskd690!#!! +No match of via \S +No match of + via \S\S +No match of +kait via \S+ +Matched !%!^^@@!^ via \W+ : 1 + match 0: !%!^^@@!^ +No match of a^#$bcABC0123_ via \W+ +Matched + via \H : 1 + match 0: + +Matched +
via \H\H : 1 + match 0: +
+No match of . via \H+ +No match of via \H\H +No match of a35 via \H+ +Matched ABCD via [^a-z]* : 1 + match 0: ABCD +Matched 1234 via [^a-zA-Z]* : 1 + match 0: 1234 +Matched -^^- via [^a-zA-Z0-9_]* : 1 + match 0: -^^- +Matched d6d via [^abc]* : 1 + match 0: d6d +Matched !^!!))# via [^a-zABC]* : 1 + match 0: !^!!))# +No match of abcd via [^a-z]* +No match of abCD via [^a-zA-Z]* +No match of _abCD018 via [^a-zA-Z0-9_]* +No match of abba via [^abc]* +No match of abBa via [^a-zABC]* diff --git a/libregex/test/data/unicode-expected b/libregex/test/data/unicode-expected new file mode 100644 index 0000000..b3028cb --- /dev/null +++ b/libregex/test/data/unicode-expected @@ -0,0 +1,13 @@ +Matched Abæc via .*bæc : 1 + match 0: Abæc +Matched Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! via (\p{L}*)bæc\P{L}* : 2 + match 0: Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + match 1: Aa +Matched Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! via (\pL*)bæc\PL* : 2 + match 0: Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + match 1: Aa +Matched Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! via (\p{Letter}*)bæc\P{Uppercase_Letter}* : 2 + match 0: Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + match 1: Aa +Matched æ via . : 1 + match 0: æ diff --git a/libregex/test/failmatch.myr b/libregex/test/failmatch.myr new file mode 100644 index 0000000..2f0c8d7 --- /dev/null +++ b/libregex/test/failmatch.myr @@ -0,0 +1,8 @@ +use std +use regex + +use "testmatch.use" + +const main = { + testmatch(".*bcd", "Abc") +} diff --git a/libregex/test/negclass.myr b/libregex/test/negclass.myr new file mode 100644 index 0000000..95ad2a4 --- /dev/null +++ b/libregex/test/negclass.myr @@ -0,0 +1,72 @@ +use std + +use "testmatch.use" + +const main = { + asciiclass() + set() + /* + unicodeclass() + negasciiclass() + negasciirange() + negset() + */ +} + +const asciiclass = { + /* \D success */ + testmatch("\\D", "x") + testmatch("\\D+", "xa!#^cs") + + /* \D fail: end of ranges chars */ + testmatch("\\D", "0") + testmatch("\\D", "9") + testmatch("\\D+", "a35x") + testmatch("\\D+", "13688") + + /* \X success */ + testmatch("\\X", "Z") + testmatch("\\X\\X", "gg") + /* \X fail */ + testmatch("\\X", "a") + testmatch("\\X+", "zz13b8cDEf") + + /* \S success */ + testmatch("\\S", "a") + testmatch("\\S\\S", "i%") + testmatch("\\S+", "alskd690!#!!") + + /* \S fail */ + testmatch("\\S", " ") + testmatch("\\S\\S", "\t\n") + testmatch("\\S+", "\t \nkait") + + /* word success */ + testmatch("\\W+", "!%!^^@@!^") + /* word fail */ + testmatch("\\W+", "a^#$bcABC0123_") + + /* \H success */ + testmatch("\\H", "\n") + testmatch("\\H\\H", "\n\r") + /* \H fail */ + testmatch("\\H+", "\t \t.") + testmatch("\\H\\H", "\t ") + testmatch("\\H+", "\ta35 \t ") +} + +const set = { + /* ranges: should succeed */ + testmatch("[^a-z]*", "ABCD") + testmatch("[^a-zA-Z]*", "1234") + testmatch("[^a-zA-Z0-9_]*", "-^^-") + testmatch("[^abc]*", "d6d") + testmatch("[^a-zABC]*", "!^!!))#") + + /* ranges: should fail */ + testmatch("[^a-z]*", "abcd") + testmatch("[^a-zA-Z]*", "abCD") + testmatch("[^a-zA-Z0-9_]*", "_abCD018") + testmatch("[^abc]*", "abba") + testmatch("[^a-zABC]*", "abBa") +} diff --git a/libregex/test/runtest.sh b/libregex/test/runtest.sh new file mode 100755 index 0000000..95f548f --- /dev/null +++ b/libregex/test/runtest.sh @@ -0,0 +1,124 @@ +#!/bin/bash +NFAILURES=0 +NPASSES=0 + +function build { + rm -f $1 $1.o $1.s $1.use + myrbuild $FLAGS -b $1 $1.myr $EXTRA_SRC +} + +function pass { + PASSED="$PASSED $1" + NPASSED=$[$NPASSED + 1] +} + +function fail { + echo "FAIL: $1" + FAILED="$FAILED $1" + NFAILED=$[$NFAILED + 1] +} + +function expectstatus { + ./$1 $3 + if [ $? -eq $2 ]; then + pass $1 + return + else + fail $1 + fi +} + +function expectprint { + if [ "`./$1 $3`" != "$2" ]; then + fail $1 + else + pass $1 + fi +} + + +function expectcompare { + if [ x"" != x"$TMPDIR" ]; then + t=$TMPDIR/myrtest-$1-$RANDOM + else + t=/tmp/myrtest-$1-$RANDOM + fi + ./$1 $3 > $t + if cmp $t data/$1-expected; then + pass $1 + else + fail $1 + fi + rm -f $t +} + +function expectfcompare { + ./$1 $3 + if cmp data/$1-expected $2; then + pass $1 + else + fail $1 + fi +} + +function shouldskip { + if [ -z $ARGS ]; then + return 1 + fi + + for i in $ARGS; do + if [ $i = $1 ]; then + return 1 + fi + done + return 0 +} + + +# Should build and run +function B { + if shouldskip $1; then + return + fi + + test="$1"; shift + type="$1"; shift + res="$1"; shift + if [ $# > 0 ]; then + args="$1"; shift + fi + build $test + case $type in + "E") expectstatus "$test" "$res" "$input";; + "P") expectprint "$test" "$res" "$input";; + "C") expectcompare "$test" "$res" "$input";; + "F") expectfcompare "$test" "$res" "$args";; + esac +} + +# Should fail +function F { + if shouldskip $1; then + return + fi + (build $1) > /dev/null + if [ $? -eq '1' ]; then + pass $1 + else + fail $1 + fi +} + +# Should generate a usefile +function U { + return +} + +source tests + +echo "PASSED ($NPASSED): $PASSED" +if [ -z "$NFAILED" ]; then + echo "SUCCESS" +else + echo "FAILURES ($NFAILED): $FAILED" +fi diff --git a/libregex/test/testmatch.myr b/libregex/test/testmatch.myr new file mode 100644 index 0000000..2c0195b --- /dev/null +++ b/libregex/test/testmatch.myr @@ -0,0 +1,34 @@ +use std +use regex + +pkg = + const testmatch : (pat : byte[:], text : byte[:] -> void) + const dbgmatch : (pat : byte[:], text : byte[:] -> void) +;; + +const testmatch = {pat, text + run(regex.compile(pat), pat, text) +} + +const dbgmatch = {pat, text + run(regex.dbgcompile(pat), pat, text) +} + +const run = {regex, pat, text + var i + match regex + | `std.Ok re: + match regex.exec(re, text) + | `std.Some m: + std.put("Matched %s via %s : %i\n", text, pat, m.len) + for i = 0; i < m.len; i++ + std.put("\tmatch %i: %s\n", i, m[i]) + ;; + | `std.None: + std.put("No match of %s via %s\n", text, pat) + ;; + regex.free(re) + | `std.Fail err: + std.put("failed to compile regex") + ;; +} diff --git a/libregex/test/tests b/libregex/test/tests new file mode 100644 index 0000000..a5f70f7 --- /dev/null +++ b/libregex/test/tests @@ -0,0 +1,29 @@ +FLAGS=-I../ +EXTRA_SRC=testmatch.myr +# Format: +# [B|F] testname [E|P] result +# [B|F]: Compiler outcome. +# B: Expect that this test will build. +# F: Expect that this test will not build. +# testname: Test case +# The test that will run. We will try to +# compile 'testname.myr' to 'testname', +# and then execute it, verifying the result +# [E|P|C]: Result type +# E tells us that the result is an exit status +# P tells us that the result is on stdout, +# and should be compared to the value on the +# line +# C tells us that the result is on stdout, +# and should be compared to the contents of +# the file passed on the line. +# result: Result value +# What we compare with. This should be self- +# evident. +B basic C +B boundaries C +B capture C +B class C +B failmatch C +B negclass C +B unicode C diff --git a/libregex/test/unicode.myr b/libregex/test/unicode.myr new file mode 100644 index 0000000..ccf7c43 --- /dev/null +++ b/libregex/test/unicode.myr @@ -0,0 +1,13 @@ +use std +use regex + +use "testmatch.use" + +const main = { + testmatch(".*bæc", "Abæc") + testmatch("(\\p{L}*)bæc\\P{L}*", "Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + /* test various syntaxen */ + testmatch("(\\pL*)bæc\\PL*", "Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + testmatch("(\\p{Letter}*)bæc\\P{Uppercase_Letter}*", "Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") + testmatch(".", "æ") +} |