tests: test regular expression validation phase
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 18 Jun 2015 19:30:29 +0000 (15:30 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Thu, 18 Jun 2015 19:31:57 +0000 (15:31 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

tests/sav/test_regex_check.res [new file with mode: 0644]
tests/sav/test_regex_check_alt1.res [new file with mode: 0644]
tests/sav/test_regex_check_alt2.res [new file with mode: 0644]
tests/sav/test_regex_check_alt3.res [new file with mode: 0644]
tests/test_regex_check.nit [new file with mode: 0644]

diff --git a/tests/sav/test_regex_check.res b/tests/sav/test_regex_check.res
new file mode 100644 (file)
index 0000000..da29283
--- /dev/null
@@ -0,0 +1,2 @@
+true
+false
diff --git a/tests/sav/test_regex_check_alt1.res b/tests/sav/test_regex_check_alt1.res
new file mode 100644 (file)
index 0000000..20bc4a2
--- /dev/null
@@ -0,0 +1 @@
+alt/test_regex_check_alt1.nit:16,10--18: Regex Error: Invalid preceding regular expression
diff --git a/tests/sav/test_regex_check_alt2.res b/tests/sav/test_regex_check_alt2.res
new file mode 100644 (file)
index 0000000..c46a3fe
--- /dev/null
@@ -0,0 +1 @@
+alt/test_regex_check_alt2.nit:17,10--19: Regex Error: Unmatched ( or \(
diff --git a/tests/sav/test_regex_check_alt3.res b/tests/sav/test_regex_check_alt3.res
new file mode 100644 (file)
index 0000000..b0fce3b
--- /dev/null
@@ -0,0 +1 @@
+alt/test_regex_check_alt3.nit:18,10--19: Regex Error: Invalid regular expression
diff --git a/tests/test_regex_check.nit b/tests/test_regex_check.nit
new file mode 100644 (file)
index 0000000..f499510
--- /dev/null
@@ -0,0 +1,21 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var re = "a+".to_re #alt1#
+#alt1#var re = "+".to_re
+#alt2#var re = "\(".to_re
+#alt3#var re = "\[".to_re
+
+print "aa".has(re)
+print "bb".has(re)