aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/test/script/lexer
diff options
context:
space:
mode:
Diffstat (limited to 'unit-tests/test/script/lexer')
-rw-r--r--unit-tests/test/script/lexer/assign-line.test8
-rw-r--r--unit-tests/test/script/lexer/buildfile3
-rw-r--r--unit-tests/test/script/lexer/driver.cxx7
-rw-r--r--unit-tests/test/script/lexer/script-line.test18
-rw-r--r--unit-tests/test/script/lexer/variable-line.test18
5 files changed, 51 insertions, 3 deletions
diff --git a/unit-tests/test/script/lexer/assign-line.test b/unit-tests/test/script/lexer/assign-line.test
new file mode 100644
index 0000000..ce3e8a1
--- /dev/null
+++ b/unit-tests/test/script/lexer/assign-line.test
@@ -0,0 +1,8 @@
+# Note: this mode auto-expires after each token.
+#
+test.arguments += assign-line
+
+$* <";" >>EOO # semi-only
+;
+<newline>
+EOO
diff --git a/unit-tests/test/script/lexer/buildfile b/unit-tests/test/script/lexer/buildfile
index a9f6be9..70be793 100644
--- a/unit-tests/test/script/lexer/buildfile
+++ b/unit-tests/test/script/lexer/buildfile
@@ -7,6 +7,7 @@
import libs = libbutl%lib{butl}
src = token lexer diagnostics utility variable name test/script/{token lexer}
-exe{driver}: cxx{driver} ../../../../build2/cxx{$src} $libs test{variable.test}
+exe{driver}: cxx{driver} ../../../../build2/cxx{$src} $libs \
+test{script-line assign-line variable-line variable}
include ../../../../build2/
diff --git a/unit-tests/test/script/lexer/driver.cxx b/unit-tests/test/script/lexer/driver.cxx
index cd7110f..e37e29d 100644
--- a/unit-tests/test/script/lexer/driver.cxx
+++ b/unit-tests/test/script/lexer/driver.cxx
@@ -42,9 +42,12 @@ namespace build2
{
cin.exceptions (istream::failbit | istream::badbit);
- // The variable mode auto-expires so we need something underneath.
+ // Some modes auto-expire so we need something underneath.
//
- bool u (m == lexer_mode::variable);
+ bool u (m == lexer_mode::assign_line ||
+ m == lexer_mode::variable_line ||
+ m == lexer_mode::variable);
+
lexer l (cin, path ("stdin"), u ? lexer_mode::script_line : m);
if (u)
l.mode (m);
diff --git a/unit-tests/test/script/lexer/script-line.test b/unit-tests/test/script/lexer/script-line.test
new file mode 100644
index 0000000..b4fe3ef
--- /dev/null
+++ b/unit-tests/test/script/lexer/script-line.test
@@ -0,0 +1,18 @@
+test.arguments += script-line
+
+$* <"cmd;" >>EOO # semi
+'cmd'
+;
+<newline>
+EOO
+
+$* <"cmd ;" >>EOO # semi-separated
+'cmd'
+;
+<newline>
+EOO
+
+$* <";" >>EOO # semi-only
+;
+<newline>
+EOO
diff --git a/unit-tests/test/script/lexer/variable-line.test b/unit-tests/test/script/lexer/variable-line.test
new file mode 100644
index 0000000..543c6f9
--- /dev/null
+++ b/unit-tests/test/script/lexer/variable-line.test
@@ -0,0 +1,18 @@
+test.arguments += variable-line
+
+$* <"cmd;" >>EOO # semi
+'cmd'
+;
+<newline>
+EOO
+
+$* <"cmd ;" >>EOO # semi-separated
+'cmd'
+;
+<newline>
+EOO
+
+$* <";" >>EOO # semi-only
+;
+<newline>
+EOO