From a1944a9d561e76b02717673647b87704118c03a6 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 20 Aug 2018 23:21:01 -0400 Subject: - More minor optimizations. - Removed ratio syntax for Frac. --- stdlib/test/test/lux/compiler/default/syntax.lux | 36 ------------------------ 1 file changed, 36 deletions(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux index 2b4a8f5b6..a9baa546c 100644 --- a/stdlib/test/test/lux/compiler/default/syntax.lux +++ b/stdlib/test/test/lux/compiler/default/syntax.lux @@ -112,42 +112,6 @@ (:: code.Equivalence = other =other))))) )))) -(context: "Frac special syntax." - (<| (times 100) - (do @ - [numerator (|> r.nat (:: @ map (|>> (n/% 100) .int int-to-frac))) - denominator (|> r.nat (:: @ map (|>> (n/% 100) (n/max 1) .int int-to-frac))) - signed? r.bit - #let [expected (|> numerator (f// denominator) (f/* (if signed? -1.0 +1.0)))]] - (test "Can parse frac ratio syntax." - (case (&.read "" (dict.new text.Hash) - [default-cursor 0 - (format (if signed? "-" "+") - (%i (frac-to-int numerator)) - "/" - (%i (frac-to-int denominator)))]) - (#e.Success [_ [_ (#.Frac actual)]]) - (f/= expected actual) - - _ - #0) - )))) - -(context: "Nat special syntax." - (<| (times 100) - (do @ - [expected (|> r.nat (:: @ map (n/% 1_000)))] - (test "Can parse nat char syntax." - (case (&.read "" (dict.new text.Hash) - [default-cursor 0 - (format "#" (%t (text.from-code expected)) "")]) - (#e.Success [_ [_ (#.Nat actual)]]) - (n/= expected actual) - - _ - #0) - )))) - (def: comment-text^ (r.Random Text) (let [char-gen (|> r.nat (r.filter (function (_ value) -- cgit v1.2.3 From 6c896325238b63b6fc09f774968be6da0b9c89c1 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 22 Aug 2018 17:40:33 -0400 Subject: No more multi-line comments. --- stdlib/test/test/lux/compiler/default/syntax.lux | 36 +++--------------------- 1 file changed, 4 insertions(+), 32 deletions(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux index a9baa546c..1bcb9dad8 100644 --- a/stdlib/test/test/lux/compiler/default/syntax.lux +++ b/stdlib/test/test/lux/compiler/default/syntax.lux @@ -114,25 +114,16 @@ (def: comment-text^ (r.Random Text) - (let [char-gen (|> r.nat (r.filter (function (_ value) - (not (or (text.space? value) - (n/= (char "#") value) - (n/= (char "(") value) - (n/= (char ")") value))))))] + (let [char-gen (|> r.nat (r.filter (|>> (n/= (char "\n")) not)))] (do r.Monad [size (|> r.nat (r/map (n/% 20)))] (r.text char-gen size)))) (def: comment^ (r.Random Text) - (r.either (do r.Monad - [comment comment-text^] - (wrap (format "## " comment "\n"))) - (r.rec (function (_ nested^) - (do r.Monad - [comment (r.either comment-text^ - nested^)] - (wrap (format "#( " comment " )#"))))))) + (do r.Monad + [comment comment-text^] + (wrap (format "## " comment "\n")))) (context: "Multi-line text & comments." (<| (seed 12137892244981970631) @@ -189,23 +180,4 @@ (#e.Success [_ parsed]) (:: code.Equivalence = parsed sample))) - (test "Will reject unbalanced multi-line comments." - (and (case (&.read "" (dict.new text.Hash) - [default-cursor 0 - (format "#(" "#(" unbalanced-comment ")#" - (code.to-text sample))]) - (#e.Error error) - #1 - - (#e.Success [_ parsed]) - #0) - (case (&.read "" (dict.new text.Hash) - [default-cursor 0 - (format "#(" unbalanced-comment ")#" ")#" - (code.to-text sample))]) - (#e.Error error) - #1 - - (#e.Success [_ parsed]) - #0))) )))) -- cgit v1.2.3 From 5e13ae0ad68947249a98dc69ab513bdbeca1697e Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 22 Aug 2018 22:50:33 -0400 Subject: No more escaping of horizontal-tab. --- stdlib/test/test/lux/compiler/default/syntax.lux | 2 +- stdlib/test/test/lux/data/text/regex.lux | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux index 1bcb9dad8..6a447e9c1 100644 --- a/stdlib/test/test/lux/compiler/default/syntax.lux +++ b/stdlib/test/test/lux/compiler/default/syntax.lux @@ -30,7 +30,7 @@ (do r.Monad [#let [digits "0123456789" delimiters "()[]{}#.\"" - space "\t\v \n\r\f" + space "\v \n\r\f" invalid-range (format digits delimiters space) char-gen (|> r.nat (:: @ map (|>> (n/% 256) (n/max 1))) diff --git a/stdlib/test/test/lux/data/text/regex.lux b/stdlib/test/test/lux/data/text/regex.lux index 96f56c3d9..7a6e88d33 100644 --- a/stdlib/test/test/lux/data/text/regex.lux +++ b/stdlib/test/test/lux/data/text/regex.lux @@ -5,7 +5,7 @@ pipe ["p" parser]] [data - [text ("text/." Equivalence) + ["." text ("text/." Equivalence) format ["." lexer (#+ Lexer)] ["&" regex]]] @@ -117,10 +117,10 @@ (and (should-pass (&.regex "\\p{OctDigit}") "6") (should-fail (&.regex "\\p{OctDigit}") ".")) - (and (should-pass (&.regex "\\p{Blank}") "\t") + (and (should-pass (&.regex "\\p{Blank}") text.tab) (should-fail (&.regex "\\p{Blank}") ".")) - (and (should-pass (&.regex "\\p{ASCII}") "\t") + (and (should-pass (&.regex "\\p{ASCII}") text.tab) (should-fail (&.regex "\\p{ASCII}") "\u1234")) (and (should-pass (&.regex "\\p{Contrl}") "\u0012") -- cgit v1.2.3 From 533864f86be183cbbb7c11516910acf711d281f4 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 22 Aug 2018 22:54:59 -0400 Subject: No more escaping of form-feed. --- stdlib/test/test/lux/compiler/default/syntax.lux | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux index 6a447e9c1..e8b5bb5b4 100644 --- a/stdlib/test/test/lux/compiler/default/syntax.lux +++ b/stdlib/test/test/lux/compiler/default/syntax.lux @@ -30,7 +30,7 @@ (do r.Monad [#let [digits "0123456789" delimiters "()[]{}#.\"" - space "\v \n\r\f" + space "\v \n\r" invalid-range (format digits delimiters space) char-gen (|> r.nat (:: @ map (|>> (n/% 256) (n/max 1))) -- cgit v1.2.3 From f4f1d14416770cc223676a7d89ed15a11222ef1b Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 22 Aug 2018 22:56:56 -0400 Subject: No more escaping of carriage-return. --- stdlib/test/test/lux/compiler/default/syntax.lux | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux index e8b5bb5b4..14de95b52 100644 --- a/stdlib/test/test/lux/compiler/default/syntax.lux +++ b/stdlib/test/test/lux/compiler/default/syntax.lux @@ -30,7 +30,7 @@ (do r.Monad [#let [digits "0123456789" delimiters "()[]{}#.\"" - space "\v \n\r" + space "\v \n" invalid-range (format digits delimiters space) char-gen (|> r.nat (:: @ map (|>> (n/% 256) (n/max 1))) -- cgit v1.2.3 From 79c2988c1b514657cc384070e66539e51e105987 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 22 Aug 2018 22:59:20 -0400 Subject: No more escaping of vertical-tab. --- stdlib/test/test/lux/compiler/default/syntax.lux | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux index 14de95b52..5ac8e16da 100644 --- a/stdlib/test/test/lux/compiler/default/syntax.lux +++ b/stdlib/test/test/lux/compiler/default/syntax.lux @@ -30,7 +30,7 @@ (do r.Monad [#let [digits "0123456789" delimiters "()[]{}#.\"" - space "\v \n" + space " \n" invalid-range (format digits delimiters space) char-gen (|> r.nat (:: @ map (|>> (n/% 256) (n/max 1))) -- cgit v1.2.3 From 324665cef68fa326d358733d36ed20feba5dbbd6 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 22 Aug 2018 23:25:04 -0400 Subject: No more escaping of unicode. --- stdlib/test/test/lux/data/text/regex.lux | 9 +++++---- stdlib/test/test/lux/math/logic/fuzzy.lux | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/data/text/regex.lux b/stdlib/test/test/lux/data/text/regex.lux index 7a6e88d33..7c54d8385 100644 --- a/stdlib/test/test/lux/data/text/regex.lux +++ b/stdlib/test/test/lux/data/text/regex.lux @@ -5,6 +5,7 @@ pipe ["p" parser]] [data + [number (#+ hex)] ["." text ("text/." Equivalence) format ["." lexer (#+ Lexer)] @@ -121,9 +122,9 @@ (should-fail (&.regex "\\p{Blank}") ".")) (and (should-pass (&.regex "\\p{ASCII}") text.tab) - (should-fail (&.regex "\\p{ASCII}") "\u1234")) + (should-fail (&.regex "\\p{ASCII}") (text.from-code (hex "1234")))) - (and (should-pass (&.regex "\\p{Contrl}") "\u0012") + (and (should-pass (&.regex "\\p{Contrl}") (text.from-code (hex "12"))) (should-fail (&.regex "\\p{Contrl}") "a")) (and (should-pass (&.regex "\\p{Punct}") "@") @@ -132,8 +133,8 @@ (and (should-pass (&.regex "\\p{Graph}") "@") (should-fail (&.regex "\\p{Graph}") " ")) - (and (should-pass (&.regex "\\p{Print}") "\u0020") - (should-fail (&.regex "\\p{Print}") "\u1234")) + (and (should-pass (&.regex "\\p{Print}") (text.from-code (hex "20"))) + (should-fail (&.regex "\\p{Print}") (text.from-code (hex "1234")))) )) )) diff --git a/stdlib/test/test/lux/math/logic/fuzzy.lux b/stdlib/test/test/lux/math/logic/fuzzy.lux index fe36a58c5..38f1cc75a 100644 --- a/stdlib/test/test/lux/math/logic/fuzzy.lux +++ b/stdlib/test/test/lux/math/logic/fuzzy.lux @@ -153,13 +153,13 @@ [#let [set-10 (set.from-list number.Hash (list.n/range 0 10))] sample (|> r.nat (:: @ map (n/% 20)))] ($_ seq - (test "Values that satisfy a predicate have membership = 1. - Values that don't have membership = 0." + (test (format "Values that satisfy a predicate have membership = 1." + "Values that don't have membership = 0.") (bit/= (r/= _.true (&.membership sample (&.from-predicate n/even?))) (n/even? sample))) - (test "Values that belong to a set have membership = 1. - Values that don't have membership = 0." + (test (format "Values that belong to a set have membership = 1." + "Values that don't have membership = 0.") (bit/= (r/= _.true (&.membership sample (&.from-set set-10))) (set.member? set-10 sample))) )))) -- cgit v1.2.3 From a89088576c4e586d3dad18f82eb451ff4eaa14fb Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 23 Aug 2018 00:03:26 -0400 Subject: No more escaping of double-quotes. --- stdlib/test/test/lux/compiler/default/syntax.lux | 45 ++---------------------- stdlib/test/test/lux/data/text/format.lux | 2 +- stdlib/test/test/lux/host.jvm.lux | 2 +- stdlib/test/test/lux/macro/code.lux | 4 +-- 4 files changed, 7 insertions(+), 46 deletions(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux index 5ac8e16da..e24779057 100644 --- a/stdlib/test/test/lux/compiler/default/syntax.lux +++ b/stdlib/test/test/lux/compiler/default/syntax.lux @@ -29,7 +29,7 @@ (r.Random Text) (do r.Monad [#let [digits "0123456789" - delimiters "()[]{}#.\"" + delimiters (format "()[]{}#." &.text-delimiter) space " \n" invalid-range (format digits delimiters space) char-gen (|> r.nat @@ -129,48 +129,9 @@ (<| (seed 12137892244981970631) ## (times 100) (do @ - [#let [char-gen (|> r.nat (r.filter (function (_ value) - (not (or (text.space? value) - (n/= (char "\"") value))))))] - x char-gen - y char-gen - z char-gen - offset-size (|> r.nat (r/map (|>> (n/% 10) (n/max 1)))) - #let [offset (text.join-with "" (list.repeat offset-size " "))] - sample code^ - comment comment^ - unbalanced-comment comment-text^] + [sample code^ + comment comment^] ($_ seq - (test "Will reject invalid multi-line text." - (let [bad-match (format (text.from-code x) "\n" - (text.from-code y) "\n" - (text.from-code z))] - (case (&.read "" (dict.new text.Hash) - [default-cursor 0 - (format "\"" bad-match "\"")]) - (#e.Error error) - #1 - - (#e.Success [_ parsed]) - #0))) - (test "Will accept valid multi-line text" - (let [good-input (format (text.from-code x) "\n" - offset (text.from-code y) "\n" - offset (text.from-code z)) - good-output (format (text.from-code x) "\n" - (text.from-code y) "\n" - (text.from-code z))] - (case (&.read "" (dict.new text.Hash) - [(|> default-cursor (update@ #.column (n/+ (dec offset-size)))) - 0 - (format "\"" good-input "\"")]) - (#e.Error error) - #0 - - (#e.Success [_ parsed]) - (:: code.Equivalence = - parsed - (code.text good-output))))) (test "Can handle comments." (case (&.read "" (dict.new text.Hash) [default-cursor 0 diff --git a/stdlib/test/test/lux/data/text/format.lux b/stdlib/test/test/lux/data/text/format.lux index bd66712a8..48cf24306 100644 --- a/stdlib/test/test/lux/data/text/format.lux +++ b/stdlib/test/test/lux/data/text/format.lux @@ -16,6 +16,6 @@ (&/= "+123" (%i +123)) (&/= "+123.456" (%f +123.456)) (&/= ".5" (%r .5)) - (&/= "\"YOLO\"" (%t "YOLO")) + (&/= (format text.double-quote "YOLO" text.double-quote) (%t "YOLO")) (&/= "User-id: +123 -- Active: #1" (format "User-id: " (%i +123) " -- Active: " (%b #1))))) ))) diff --git a/stdlib/test/test/lux/host.jvm.lux b/stdlib/test/test/lux/host.jvm.lux index 8832bb3f6..835bdd719 100644 --- a/stdlib/test/test/lux/host.jvm.lux +++ b/stdlib/test/test/lux/host.jvm.lux @@ -88,7 +88,7 @@ (&.instance? Object "") (not (&.instance? Object (&.null))))) - (test "Can run code in a \"synchronized\" block." + (test "Can run code in a 'synchronized' block." (&.synchronized "" #1)) (test "Can access Class instances." diff --git a/stdlib/test/test/lux/macro/code.lux b/stdlib/test/test/lux/macro/code.lux index 1e0d4a606..be53adfad 100644 --- a/stdlib/test/test/lux/macro/code.lux +++ b/stdlib/test/test/lux/macro/code.lux @@ -5,7 +5,7 @@ [monad (#+ do Monad)]] [data [number] - [text ("text/." Equivalence) + ["." text ("text/." Equivalence) format]] [math ["r" random]] [macro ["&" code]]] @@ -22,7 +22,7 @@ [(&.bit #0) "#0"] [(&.int +123) "+123"] [(&.frac +123.0) "+123.0"] - [(&.text "\n") "\"\\n\""] + [(&.text "1234") (format text.double-quote "1234" text.double-quote)] [(&.tag ["yolo" "lol"]) "#yolo.lol"] [(&.identifier ["yolo" "lol"]) "yolo.lol"] [(&.form (list (&.bit #1) (&.int +123))) "(#1 +123)"] -- cgit v1.2.3 From bc251026c21590da76085bc0bc9abeaa5ec242b6 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 23 Aug 2018 00:56:59 -0400 Subject: No more escaping of new-line. --- stdlib/test/test/lux/compiler/default/syntax.lux | 6 +++--- stdlib/test/test/lux/macro/syntax.lux | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux index e24779057..829199aa8 100644 --- a/stdlib/test/test/lux/compiler/default/syntax.lux +++ b/stdlib/test/test/lux/compiler/default/syntax.lux @@ -30,7 +30,7 @@ (do r.Monad [#let [digits "0123456789" delimiters (format "()[]{}#." &.text-delimiter) - space " \n" + space (format " " text.new-line) invalid-range (format digits delimiters space) char-gen (|> r.nat (:: @ map (|>> (n/% 256) (n/max 1))) @@ -114,7 +114,7 @@ (def: comment-text^ (r.Random Text) - (let [char-gen (|> r.nat (r.filter (|>> (n/= (char "\n")) not)))] + (let [char-gen (|> r.nat (r.filter (|>> (n/= (`` (char (~~ (static text.new-line))))) not)))] (do r.Monad [size (|> r.nat (r/map (n/% 20)))] (r.text char-gen size)))) @@ -123,7 +123,7 @@ (r.Random Text) (do r.Monad [comment comment-text^] - (wrap (format "## " comment "\n")))) + (wrap (format "## " comment text.new-line)))) (context: "Multi-line text & comments." (<| (seed 12137892244981970631) diff --git a/stdlib/test/test/lux/macro/syntax.lux b/stdlib/test/test/lux/macro/syntax.lux index b1e2f445b..0bf7b8804 100644 --- a/stdlib/test/test/lux/macro/syntax.lux +++ b/stdlib/test/test/lux/macro/syntax.lux @@ -75,9 +75,9 @@ ["Can parse Bit syntax." #1 code.bit bit.Equivalence s.bit] ["Can parse Nat syntax." 123 code.nat number.Equivalence s.nat] ["Can parse Int syntax." +123 code.int number.Equivalence s.int] - ["Can parse Rev syntax." .123 code.rev number.Equivalence s.rev] + ["Can parse Rev syntax." .123 code.rev number.Equivalence s.rev] ["Can parse Frac syntax." +123.0 code.frac number.Equivalence s.frac] - ["Can parse Text syntax." "\n" code.text text.Equivalence s.text] + ["Can parse Text syntax." text.new-line code.text text.Equivalence s.text] ["Can parse Identifier syntax." ["yolo" "lol"] code.identifier name.Equivalence s.identifier] ["Can parse Tag syntax." ["yolo" "lol"] code.tag name.Equivalence s.tag] )] -- cgit v1.2.3 From 7e312258b13c5fc9c80079fede0e41d479a8a327 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 23 Aug 2018 01:24:29 -0400 Subject: No more escaping of back-slash. --- stdlib/test/test/lux/data/text/regex.lux | 102 +++++++++++++++---------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/data/text/regex.lux b/stdlib/test/test/lux/data/text/regex.lux index 7c54d8385..3398f4685 100644 --- a/stdlib/test/test/lux/data/text/regex.lux +++ b/stdlib/test/test/lux/data/text/regex.lux @@ -53,8 +53,8 @@ (test "Can parse character literals." (and (should-pass (&.regex "a") "a") (should-fail (&.regex "a") ".") - (should-pass (&.regex "\\.") ".") - (should-fail (&.regex "\\.") "a")))) + (should-pass (&.regex "\.") ".") + (should-fail (&.regex "\.") "a")))) (context: "Regular Expressions [System character classes]" ($_ seq @@ -62,79 +62,79 @@ (should-pass (&.regex ".") "a")) (test "Can parse digits." - (and (should-pass (&.regex "\\d") "0") - (should-fail (&.regex "\\d") "m"))) + (and (should-pass (&.regex "\d") "0") + (should-fail (&.regex "\d") "m"))) (test "Can parse non digits." - (and (should-pass (&.regex "\\D") "m") - (should-fail (&.regex "\\D") "0"))) + (and (should-pass (&.regex "\D") "m") + (should-fail (&.regex "\D") "0"))) (test "Can parse white-space." - (and (should-pass (&.regex "\\s") " ") - (should-fail (&.regex "\\s") "m"))) + (and (should-pass (&.regex "\s") " ") + (should-fail (&.regex "\s") "m"))) (test "Can parse non white-space." - (and (should-pass (&.regex "\\S") "m") - (should-fail (&.regex "\\S") " "))) + (and (should-pass (&.regex "\S") "m") + (should-fail (&.regex "\S") " "))) (test "Can parse word characters." - (and (should-pass (&.regex "\\w") "_") - (should-fail (&.regex "\\w") "^"))) + (and (should-pass (&.regex "\w") "_") + (should-fail (&.regex "\w") "^"))) (test "Can parse non word characters." - (and (should-pass (&.regex "\\W") ".") - (should-fail (&.regex "\\W") "a"))) + (and (should-pass (&.regex "\W") ".") + (should-fail (&.regex "\W") "a"))) )) (context: "Regular Expressions [Special system character classes : Part 1]" ($_ seq (test "Can parse using special character classes." - (and (and (should-pass (&.regex "\\p{Lower}") "m") - (should-fail (&.regex "\\p{Lower}") "M")) + (and (and (should-pass (&.regex "\p{Lower}") "m") + (should-fail (&.regex "\p{Lower}") "M")) - (and (should-pass (&.regex "\\p{Upper}") "M") - (should-fail (&.regex "\\p{Upper}") "m")) + (and (should-pass (&.regex "\p{Upper}") "M") + (should-fail (&.regex "\p{Upper}") "m")) - (and (should-pass (&.regex "\\p{Alpha}") "M") - (should-fail (&.regex "\\p{Alpha}") "0")) + (and (should-pass (&.regex "\p{Alpha}") "M") + (should-fail (&.regex "\p{Alpha}") "0")) - (and (should-pass (&.regex "\\p{Digit}") "1") - (should-fail (&.regex "\\p{Digit}") "n")) + (and (should-pass (&.regex "\p{Digit}") "1") + (should-fail (&.regex "\p{Digit}") "n")) - (and (should-pass (&.regex "\\p{Alnum}") "1") - (should-fail (&.regex "\\p{Alnum}") ".")) + (and (should-pass (&.regex "\p{Alnum}") "1") + (should-fail (&.regex "\p{Alnum}") ".")) - (and (should-pass (&.regex "\\p{Space}") " ") - (should-fail (&.regex "\\p{Space}") ".")) + (and (should-pass (&.regex "\p{Space}") " ") + (should-fail (&.regex "\p{Space}") ".")) )) )) (context: "Regular Expressions [Special system character classes : Part 2]" ($_ seq (test "Can parse using special character classes." - (and (and (should-pass (&.regex "\\p{HexDigit}") "a") - (should-fail (&.regex "\\p{HexDigit}") ".")) + (and (and (should-pass (&.regex "\p{HexDigit}") "a") + (should-fail (&.regex "\p{HexDigit}") ".")) - (and (should-pass (&.regex "\\p{OctDigit}") "6") - (should-fail (&.regex "\\p{OctDigit}") ".")) + (and (should-pass (&.regex "\p{OctDigit}") "6") + (should-fail (&.regex "\p{OctDigit}") ".")) - (and (should-pass (&.regex "\\p{Blank}") text.tab) - (should-fail (&.regex "\\p{Blank}") ".")) + (and (should-pass (&.regex "\p{Blank}") text.tab) + (should-fail (&.regex "\p{Blank}") ".")) - (and (should-pass (&.regex "\\p{ASCII}") text.tab) - (should-fail (&.regex "\\p{ASCII}") (text.from-code (hex "1234")))) + (and (should-pass (&.regex "\p{ASCII}") text.tab) + (should-fail (&.regex "\p{ASCII}") (text.from-code (hex "1234")))) - (and (should-pass (&.regex "\\p{Contrl}") (text.from-code (hex "12"))) - (should-fail (&.regex "\\p{Contrl}") "a")) + (and (should-pass (&.regex "\p{Contrl}") (text.from-code (hex "12"))) + (should-fail (&.regex "\p{Contrl}") "a")) - (and (should-pass (&.regex "\\p{Punct}") "@") - (should-fail (&.regex "\\p{Punct}") "a")) + (and (should-pass (&.regex "\p{Punct}") "@") + (should-fail (&.regex "\p{Punct}") "a")) - (and (should-pass (&.regex "\\p{Graph}") "@") - (should-fail (&.regex "\\p{Graph}") " ")) + (and (should-pass (&.regex "\p{Graph}") "@") + (should-fail (&.regex "\p{Graph}") " ")) - (and (should-pass (&.regex "\\p{Print}") (text.from-code (hex "20"))) - (should-fail (&.regex "\\p{Print}") (text.from-code (hex "1234")))) + (and (should-pass (&.regex "\p{Print}") (text.from-code (hex "20"))) + (should-fail (&.regex "\p{Print}") (text.from-code (hex "1234")))) )) )) @@ -191,9 +191,9 @@ )) (context: "Regular Expressions [Reference]" - (let [number (&.regex "\\d+")] + (let [number (&.regex "\d+")] (test "Can build complex regexs by combining simpler ones." - (should-check ["809-345-6789" "809" "345" "6789"] (&.regex "(\\@)-(\\@)-(\\@)") "809-345-6789")))) + (should-check ["809-345-6789" "809" "345" "6789"] (&.regex "(\@)-(\@)-(\@)") "809-345-6789")))) (context: "Regular Expressions [Fuzzy Quantifiers]" ($_ seq @@ -240,14 +240,14 @@ (test "Can extract groups of sub-matches specified in a pattern." (and (should-check ["abc" "b"] (&.regex "a(.)c") "abc") (should-check ["abbbbbc" "bbbbb"] (&.regex "a(b+)c") "abbbbbc") - (should-check ["809-345-6789" "809" "345" "6789"] (&.regex "(\\d{3})-(\\d{3})-(\\d{4})") "809-345-6789") - (should-check ["809-345-6789" "809" "6789"] (&.regex "(\\d{3})-(?:\\d{3})-(\\d{4})") "809-345-6789") - (should-check ["809-809-6789" "809" "6789"] (&.regex "(\\d{3})-\\0-(\\d{4})") "809-809-6789") - (should-check ["809-809-6789" "809" "6789"] (&.regex "(?\\d{3})-\\k-(\\d{4})") "809-809-6789") - (should-check ["809-809-6789-6789" "809" "6789"] (&.regex "(?\\d{3})-\\k-(\\d{4})-\\0") "809-809-6789-6789"))) + (should-check ["809-345-6789" "809" "345" "6789"] (&.regex "(\d{3})-(\d{3})-(\d{4})") "809-345-6789") + (should-check ["809-345-6789" "809" "6789"] (&.regex "(\d{3})-(?:\d{3})-(\d{4})") "809-345-6789") + (should-check ["809-809-6789" "809" "6789"] (&.regex "(\d{3})-\0-(\d{4})") "809-809-6789") + (should-check ["809-809-6789" "809" "6789"] (&.regex "(?\d{3})-\k-(\d{4})") "809-809-6789") + (should-check ["809-809-6789-6789" "809" "6789"] (&.regex "(?\d{3})-\k-(\d{4})-\0") "809-809-6789-6789"))) (test "Can specify groups within groups." - (should-check ["809-345-6789" "809" ["345-6789" "345" "6789"]] (&.regex "(\\d{3})-((\\d{3})-(\\d{4}))") "809-345-6789")) + (should-check ["809-345-6789" "809" ["345-6789" "345" "6789"]] (&.regex "(\d{3})-((\d{3})-(\d{4}))") "809-345-6789")) )) (context: "Regular Expressions [Alternation]" @@ -263,7 +263,7 @@ (should-fail (&.regex "a(.)(.)|b(.)(.)") "cde") (should-check ["809-345-6789" (0 ["809" "345-6789" "345" "6789"])] - (&.regex "(\\d{3})-((\\d{3})-(\\d{4}))|b(.)d") + (&.regex "(\d{3})-((\d{3})-(\d{4}))|b(.)d") "809-345-6789"))) )) -- cgit v1.2.3 From d9965e587905cd715ecd4c7150236d660321a02c Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 23 Aug 2018 17:18:30 -0400 Subject: Optimized text clipping. --- .../default/phase/analysis/procedure/common.lux | 2 +- stdlib/test/test/lux/compiler/default/syntax.lux | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux index fc082155a..cfc164df9 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux @@ -167,7 +167,7 @@ (test "Can obtain the character code of a text at a given index." (check-success+ "lux text char" (list subjectC fromC) (type (Maybe Nat)))) (test "Can clip a piece of text between 2 indices." - (check-success+ "lux text clip" (list subjectC fromC toC) (type (Maybe Text)))) + (check-success+ "lux text clip" (list subjectC fromC toC) Text)) )))) (context: "IO procedures" diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux index 829199aa8..887765cbd 100644 --- a/stdlib/test/test/lux/compiler/default/syntax.lux +++ b/stdlib/test/test/lux/compiler/default/syntax.lux @@ -87,23 +87,23 @@ other code^] ($_ seq (test "Can parse Lux code." - (case (&.read "" (dict.new text.Hash) - [default-cursor 0 (code.to-text sample)]) + (case (&.parse "" (dict.new text.Hash) + [default-cursor 0 (code.to-text sample)]) (#e.Error error) #0 (#e.Success [_ parsed]) (:: code.Equivalence = parsed sample))) (test "Can parse Lux multiple code nodes." - (case (&.read "" (dict.new text.Hash) - [default-cursor 0 (format (code.to-text sample) " " - (code.to-text other))]) + (case (&.parse "" (dict.new text.Hash) + [default-cursor 0 (format (code.to-text sample) " " + (code.to-text other))]) (#e.Error error) #0 (#e.Success [remaining =sample]) - (case (&.read "" (dict.new text.Hash) - remaining) + (case (&.parse "" (dict.new text.Hash) + remaining) (#e.Error error) #0 @@ -133,9 +133,9 @@ comment comment^] ($_ seq (test "Can handle comments." - (case (&.read "" (dict.new text.Hash) - [default-cursor 0 - (format comment (code.to-text sample))]) + (case (&.parse "" (dict.new text.Hash) + [default-cursor 0 + (format comment (code.to-text sample))]) (#e.Error error) #0 -- cgit v1.2.3 From 312cc7dc5f0be0ef0a48ea8470d8ee64b929bc7b Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 23 Aug 2018 19:02:47 -0400 Subject: "lux text char" is now unsafe/optimized. --- .../test/test/lux/compiler/default/phase/analysis/procedure/common.lux | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux index cfc164df9..108b350d0 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux @@ -165,7 +165,7 @@ (test "Can query the size/length of a text." (check-success+ "lux text size" (list subjectC) Nat)) (test "Can obtain the character code of a text at a given index." - (check-success+ "lux text char" (list subjectC fromC) (type (Maybe Nat)))) + (check-success+ "lux text char" (list subjectC fromC) Nat)) (test "Can clip a piece of text between 2 indices." (check-success+ "lux text clip" (list subjectC fromC toC) Text)) )))) -- cgit v1.2.3