From 6055cddab2df83d4541e5208f08bcf6056d22b32 Mon Sep 17 00:00:00 2001 From: "Johan B.W. de Vries" Date: Sun, 4 May 2025 12:40:40 +0200 Subject: [PATCH] Extends the test framework to prepare for compilation tests Feat: add now can add two full strings Fix: it2 would have different working for emit eof Fix: eq and lt would return bools on it0 and it1 Fix: Functions always return something (there is no such thing as an empty type). Fix: Return value from main is now always ignored. Fix: Output from check is same on all iterations --- 0-lang0py/lang0py.py | 34 +++--- 1-lang0py/lang0py.lang0 | 42 ++++--- 2-lang0c/lang0c.lang0 | 51 ++++++--- README.md | 22 +++- tests/.gitignore | 2 +- tests/Makefile | 41 ++++--- tests/build/{ => test_builtins}/.gitignore | 9 ++ tests/build/test_flow_control/.gitignore | 23 ++++ tests/build/test_parsing/.gitignore | 23 ++++ tests/build/test_stdlib_constants/.gitignore | 23 ++++ tests/build/test_stdlib_functions/.gitignore | 23 ++++ tests/build/test_variables/.gitignore | 23 ++++ tests/builtincheckfalse.lang0 | 3 - tests/builtinchecktrue.lang0 | 4 - tests/flowiffalse.lang0 | 8 -- tests/flowiftrue.lang0 | 7 -- tests/flowreturnnothing.lang0 | 8 -- tests/flowreturnvalue.lang0 | 11 -- tests/flowreturnvalueconstant.lang0 | 9 -- tests/generate-recipes.py | 106 ++++++++++++++++++ tests/parsingpredeclaredfunction0.lang0 | 10 -- tests/parsingpredeclaredfunction1.lang0 | 10 -- tests/stdinlineno.lang0 | 86 -------------- tests/stdlibaddstringchar.lang0 | 6 - tests/stdlibemit.lang0 | 3 - tests/stdlibeqfalse.lang0 | 6 - tests/stdlibeqtrue.lang0 | 5 - tests/stdlibltfalse.lang0 | 6 - tests/stdliblttrue.lang0 | 5 - tests/stdlibpeek.lang0 | 6 - tests/stdlibskip.lang0 | 12 -- tests/test-input.txt | 3 - tests/test_builtins/test_check.exp.stderr | 1 + tests/test_builtins/test_check.exp.stdout | 1 + tests/test_builtins/test_check.lang0 | 8 ++ tests/test_flow_control/test_break.exp.stdout | 1 + .../test_break.lang0} | 3 +- tests/test_flow_control/test_call.exp.stdout | 1 + .../test_call.lang0} | 0 tests/test_flow_control/test_if.exp.stdout | 2 + tests/test_flow_control/test_if.lang0 | 18 +++ .../test_flow_control/test_return.exp.stdout | 3 + tests/test_flow_control/test_return.lang0 | 32 ++++++ .../test_predeclare_functions.exp.stdout | 2 + .../test_predeclare_functions.lang0 | 24 ++++ .../test_stdlib_constants/test_eof.exp.stdout | 1 + tests/test_stdlib_constants/test_eof.lang0 | 3 + .../test_stdlib_constants/test_eol.exp.stdout | 1 + tests/test_stdlib_constants/test_eol.lang0 | 3 + .../test_quote.exp.stdout | 1 + tests/test_stdlib_constants/test_quote.lang0 | 3 + .../test_stdlib_functions/test_add.exp.stdout | 3 + tests/test_stdlib_functions/test_add.lang0 | 29 +++++ .../test_emit.exp.stdout | 1 + tests/test_stdlib_functions/test_emit.lang0 | 4 + .../test_stdlib_functions/test_eq.exp.stdout | 4 + tests/test_stdlib_functions/test_eq.lang0 | 19 ++++ .../test_stdlib_functions/test_lt.exp.stdout | 6 + tests/test_stdlib_functions/test_lt.lang0 | 27 +++++ .../test_peek.exp.stdout | 1 + tests/test_stdlib_functions/test_peek.lang0 | 9 ++ tests/test_stdlib_functions/test_peek.stdin | 1 + .../test_skip.exp.stdout | 1 + tests/test_stdlib_functions/test_skip.lang0 | 12 ++ tests/test_stdlib_functions/test_skip.stdin | 1 + .../test_stdincolno.exp.stdout | 4 + .../test_stdincolno.lang0 | 35 ++++++ .../test_stdincolno.stdin | 3 + .../test_stdinlineno.exp.stdout | 4 + .../test_stdinlineno.lang0 | 35 ++++++ .../test_stdinlineno.stdin | 3 + tests/test_variables/test_calc.exp.stdout | 1 + .../test_calc.lang0} | 0 tests/test_variables/test_set.exp.stdout | 1 + .../test_set.lang0} | 0 75 files changed, 660 insertions(+), 282 deletions(-) rename tests/build/{ => test_builtins}/.gitignore (51%) create mode 100644 tests/build/test_flow_control/.gitignore create mode 100644 tests/build/test_parsing/.gitignore create mode 100644 tests/build/test_stdlib_constants/.gitignore create mode 100644 tests/build/test_stdlib_functions/.gitignore create mode 100644 tests/build/test_variables/.gitignore delete mode 100644 tests/builtincheckfalse.lang0 delete mode 100644 tests/builtinchecktrue.lang0 delete mode 100644 tests/flowiffalse.lang0 delete mode 100644 tests/flowiftrue.lang0 delete mode 100644 tests/flowreturnnothing.lang0 delete mode 100644 tests/flowreturnvalue.lang0 delete mode 100644 tests/flowreturnvalueconstant.lang0 create mode 100644 tests/generate-recipes.py delete mode 100644 tests/parsingpredeclaredfunction0.lang0 delete mode 100644 tests/parsingpredeclaredfunction1.lang0 delete mode 100644 tests/stdinlineno.lang0 delete mode 100644 tests/stdlibaddstringchar.lang0 delete mode 100644 tests/stdlibemit.lang0 delete mode 100644 tests/stdlibeqfalse.lang0 delete mode 100644 tests/stdlibeqtrue.lang0 delete mode 100644 tests/stdlibltfalse.lang0 delete mode 100644 tests/stdliblttrue.lang0 delete mode 100644 tests/stdlibpeek.lang0 delete mode 100644 tests/stdlibskip.lang0 delete mode 100644 tests/test-input.txt create mode 100644 tests/test_builtins/test_check.exp.stderr create mode 100644 tests/test_builtins/test_check.exp.stdout create mode 100644 tests/test_builtins/test_check.lang0 create mode 100644 tests/test_flow_control/test_break.exp.stdout rename tests/{flowbreak.lang0 => test_flow_control/test_break.lang0} (51%) create mode 100644 tests/test_flow_control/test_call.exp.stdout rename tests/{flowcall.lang0 => test_flow_control/test_call.lang0} (100%) create mode 100644 tests/test_flow_control/test_if.exp.stdout create mode 100644 tests/test_flow_control/test_if.lang0 create mode 100644 tests/test_flow_control/test_return.exp.stdout create mode 100644 tests/test_flow_control/test_return.lang0 create mode 100644 tests/test_parsing/test_predeclare_functions.exp.stdout create mode 100644 tests/test_parsing/test_predeclare_functions.lang0 create mode 100644 tests/test_stdlib_constants/test_eof.exp.stdout create mode 100644 tests/test_stdlib_constants/test_eof.lang0 create mode 100644 tests/test_stdlib_constants/test_eol.exp.stdout create mode 100644 tests/test_stdlib_constants/test_eol.lang0 create mode 100644 tests/test_stdlib_constants/test_quote.exp.stdout create mode 100644 tests/test_stdlib_constants/test_quote.lang0 create mode 100644 tests/test_stdlib_functions/test_add.exp.stdout create mode 100644 tests/test_stdlib_functions/test_add.lang0 create mode 100644 tests/test_stdlib_functions/test_emit.exp.stdout create mode 100644 tests/test_stdlib_functions/test_emit.lang0 create mode 100644 tests/test_stdlib_functions/test_eq.exp.stdout create mode 100644 tests/test_stdlib_functions/test_eq.lang0 create mode 100644 tests/test_stdlib_functions/test_lt.exp.stdout create mode 100644 tests/test_stdlib_functions/test_lt.lang0 create mode 100644 tests/test_stdlib_functions/test_peek.exp.stdout create mode 100644 tests/test_stdlib_functions/test_peek.lang0 create mode 100644 tests/test_stdlib_functions/test_peek.stdin create mode 100644 tests/test_stdlib_functions/test_skip.exp.stdout create mode 100644 tests/test_stdlib_functions/test_skip.lang0 create mode 100644 tests/test_stdlib_functions/test_skip.stdin create mode 100644 tests/test_stdlib_functions/test_stdincolno.exp.stdout create mode 100644 tests/test_stdlib_functions/test_stdincolno.lang0 create mode 100644 tests/test_stdlib_functions/test_stdincolno.stdin create mode 100644 tests/test_stdlib_functions/test_stdinlineno.exp.stdout create mode 100644 tests/test_stdlib_functions/test_stdinlineno.lang0 create mode 100644 tests/test_stdlib_functions/test_stdinlineno.stdin create mode 100644 tests/test_variables/test_calc.exp.stdout rename tests/{variablescalc.lang0 => test_variables/test_calc.lang0} (100%) create mode 100644 tests/test_variables/test_set.exp.stdout rename tests/{variablesset.lang0 => test_variables/test_set.lang0} (100%) diff --git a/0-lang0py/lang0py.py b/0-lang0py/lang0py.py index 7de85d1..295898b 100644 --- a/0-lang0py/lang0py.py +++ b/0-lang0py/lang0py.py @@ -2,14 +2,14 @@ import os import sys def emit(string): - sys.stdout.write(string) + sys.stdout.buffer.write(string.encode('latin_1')) sys.stdout.flush() def trace(header, value): if os.environ.get('TRACE'): sys.stderr.write(f'{header}={value!r}\n') -eof = chr(0) +eof = chr(0xFF) eol = chr(10) quote = chr(34) PEEK = None @@ -166,13 +166,15 @@ def parsestatreturn(indent): parseconststring() else: parseexprvarref() + else: + emit('""') emit(eol) skipchar(eol) def parsestatcheck(indent): skipchar(' ') emit(' ' * indent) - emit('assert ') + emit('if not ') func_name = lexident() emit(func_name) @@ -197,7 +199,9 @@ def parsestatcheck(indent): skipchar(':') - emit('), (') + emitln('):') + emit(' ' * (indent + 1)) + emit('sys.stderr.write(\' \'.join(["ERROR:", ') notfirst = False while True: @@ -214,7 +218,11 @@ def parsestatcheck(indent): if eol == peek(): break notfirst = True - emitln(')') + emitln(']))') + emit(' ' * (indent + 1)) + emitln('sys.stderr.write(eol)') + emit(' ' * (indent + 1)) + emitln('sys.exit(1)') def parsestattrace(indent): skipchar(' ') @@ -344,24 +352,24 @@ def emitheader(): emitln("import os") emitln("import sys") emitln("") - emitln("def eq(a, b):") - emitln(" return a == b") + emitln("def eq(a: str, b: str) -> str:") + emitln(" return '1' if a == b else ''") emitln("") - emitln("def lt(a, b):") - emitln(" return a[0] < b[0]") + emitln("def lt(a: str, b: str) -> str:") + emitln(" return '1' if a < b else ''") emitln("") - emitln("def addstringchar(a, b):") - emitln(" return a + b[0]") + emitln("def add(a: str, b: str) -> str:") + emitln(" return a + b") emitln("") emitln("def emit(string):") - emitln(" sys.stdout.write(string)") + emitln(" sys.stdout.buffer.write(string.encode('latin_1'))") emitln(" sys.stdout.flush()") emitln("") emitln("def trace(header, value):") emitln(" if os.environ.get('TRACE'):") emitln(" sys.stderr.write(f'{header}={value!r}\\n')") emitln("") - emitln("eof = chr(0)") + emitln("eof = chr(0xFF)") emitln("eol = chr(10)") emitln("quote = chr(34)") emitln("") diff --git a/1-lang0py/lang0py.lang0 b/1-lang0py/lang0py.lang0 index d153d14..abfa2f9 100644 --- a/1-lang0py/lang0py.lang0 +++ b/1-lang0py/lang0py.lang0 @@ -15,10 +15,7 @@ emitln data: / increaseindent indent: - calc indent addstringchar indent " " - calc indent addstringchar indent " " - calc indent addstringchar indent " " - calc indent addstringchar indent " " + calc indent add indent " " return indent / @@ -35,7 +32,7 @@ lexident: if isafterz break / - calc word addstringchar word char + calc word add word char skip / return word @@ -160,6 +157,7 @@ parsestatreturn indent: emit "return " calc char peek calc isspace eq char " " + calc isnotspace not isspace if isspace skip calc char peek @@ -172,6 +170,10 @@ parsestatreturn indent: parseexprvarref / / + if isnotspace + emit quote + emit quote + / emit eol skipchar eol / @@ -186,7 +188,7 @@ parsestatcheck indent: skipchar " " emit indent - emit "assert " + emit "if not " calc funcname lexident emit funcname @@ -220,7 +222,11 @@ parsestatcheck indent: skipchar ":" - emit "), (" + emitln "):" + calc indent increaseindent indent + emit indent + emit "sys.stderr.write(' '.join(['ERROR:', " + set notfirst "" forever @@ -249,7 +255,11 @@ parsestatcheck indent: set notfirst "1" / - emitln ")" + emitln "]))" + emit indent + emitln "sys.stderr.write(eol)" + emit indent + emitln "sys.exit(1)" / parsestattrace indent: @@ -421,24 +431,24 @@ emitheader: emitln "import os" emitln "import sys" emitln "" - emitln "def eq(a, b):" - emitln " return a == b" + emitln "def eq(a: str, b: str) -> str:" + emitln " return '1' if a == b else ''" emitln "" - emitln "def lt(a, b):" - emitln " return a[0] < b[0]" + emitln "def lt(a: str, b: str) -> str:" + emitln " return '1' if a < b else ''" emitln "" - emitln "def addstringchar(a, b):" - emitln " return a + b[0]" + emitln "def add(a: str, b :str) -> str:" + emitln " return a + b" emitln "" emitln "def emit(string):" - emitln " sys.stdout.write(string)" + emitln " sys.stdout.buffer.write(string.encode('latin_1'))" emitln " sys.stdout.flush()" emitln "" emitln "def trace(header, value):" emitln " if os.environ.get('TRACE'):" emitln " sys.stderr.write(f'{header}={value!r}\\n')" emitln "" - emitln "eof = chr(0)" + emitln "eof = chr(0xFF)" emitln "eol = chr(10)" emitln "quote = chr(34)" emitln "" diff --git a/2-lang0c/lang0c.lang0 b/2-lang0c/lang0c.lang0 index 9c19c72..96066cd 100644 --- a/2-lang0c/lang0c.lang0 +++ b/2-lang0c/lang0c.lang0 @@ -15,10 +15,7 @@ emitln data: / increaseindent indent: - calc indent addstringchar indent " " - calc indent addstringchar indent " " - calc indent addstringchar indent " " - calc indent addstringchar indent " " + calc indent add indent " " return indent / @@ -38,7 +35,7 @@ lexident: if isafterz break / - calc word addstringchar word char + calc word add word char skip / return word @@ -227,7 +224,8 @@ parsestatreturn indent: / / if isnotspace - emit "0" + emit quote + emit quote / emit ";" emit eol @@ -284,6 +282,7 @@ parsestatcheck indent: emit indent emitln "{" + emit indent emit " fprintf(stderr, " emit quote emit "%s" @@ -321,6 +320,14 @@ parsestatcheck indent: / / + emit indent + emit " fprintf(stderr, " + emit quote + emit "%s" + emit quote + emit ", var_eol" + emitln ");" + emit indent emitln " exit(1);" emit indent @@ -479,14 +486,23 @@ parsefunc: declare funcname declare iseoblock declare isfirst + declare ismain + declare isnotmain declare isspace declare isnotfirst declare isnotspace declare var calc funcname lexident + calc ismain eq funcname "main" + calc isnotmain not ismain trace funcname emit "char * " - emit funcname + if ismain + emit "__main" + / + if isnotmain + emit funcname + / emit "(" set first "1" forever @@ -532,7 +548,7 @@ emitheader: emitln "#include " emitln "" emitln "" - emitln "char var_eof[2] = {-1, 0};" + emitln "char var_eof[2] = {0xFF, 0};" emitln "char var_eol[2] = {10, 0};" emitln "char var_quote[2] = {34, 0};" emitln "char var_false[1] = {0};" @@ -553,14 +569,14 @@ emitheader: emitln " return (strcmp(a, var_true) != 0) ? var_true : var_false;" emitln "}" emitln "" - emitln "char * addstringchar(char * str, char * chr)" + emitln "char * add(char * lft, char * rgt)" emitln "{" - emitln " int str_len = strlen(str);" - emitln " assert(strlen(chr) == 1);" - emitln " char * res = malloc((str_len + 2) * sizeof(char));" - emitln " strcpy(res, str);" - emitln " res[str_len + 0] = chr[0];" - emitln " res[str_len + 1] = 0;" + emitln " int lft_len = strlen(lft);" + emitln " int rgt_len = strlen(rgt);" + emitln " char * res = malloc((lft_len + rgt_len + 1) * sizeof(char));" + emitln " strcpy(res, lft);" + emitln " strcpy(res + lft_len, rgt);" + emitln " res[lft_len + rgt_len] = 0;" emitln " return res;" emitln "}" emitln "" @@ -644,7 +660,10 @@ emitheader: / emitfooter: - emit "" + emitln "int main() {" + emitln " __main();" + emitln " return 0;" + emitln "}" return / diff --git a/README.md b/README.md index 1bee0d4..1ddb987 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Exits the deepest `forever` loop. #### func args* -Calls the function name `func` with the given arguments. The result, if any, is ignored. +Calls the function name `func` with the given arguments. The return value is ignored. #### if arg @@ -109,7 +109,7 @@ Repeats the block until `break` or `return` is called. #### return var? -Returns the given value. You can not give an argument if your function is never used in `call`. +Returns the given value. If you don't give something to return, the function will return the empty string. ### Builtins @@ -121,11 +121,23 @@ Calls the given function with the given arguments. If the function's return valu Writes the name and value of the variable passed to stderr if the TRACE environment variable is set. +### Standard library constants + +#### eof + +End of file character, zero byte. + +#### eol + +End of line character. + +#### quote + +Double quote character. + ### Standard library functions -#### addstringchar a b - -`b` is expected to have length 1. +#### add a b Creates a new string with `b` appended to `a`. diff --git a/tests/.gitignore b/tests/.gitignore index fa47d71..1417f60 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1 +1 @@ -/*.results +/Makefile.mk diff --git a/tests/Makefile b/tests/Makefile index 47dea90..d2eee94 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,6 +1,5 @@ .SUFFIXES: .PHONY: all clean -.PRECIOUS: build/%.it0.py build/%.it0.c .DELETE_ON_ERROR: PYVERSION=3.12 @@ -8,31 +7,29 @@ PYPREFIX=/usr CYTHON=cython3 CC=gcc -# builtincheckfalse is separate since it's supposed to crash. It's a test for the test 'framework', if you will. -TESTLIST=$(shell ls *.lang0 | grep -v 'builtincheckfalse' | sed 's/.lang0//') +all: verify-results -all: check +Makefile.mk: generate-recipes.py $(wildcard test_*/test_*) + python3 generate-recipes.py Makefile.mk it0 it1 it2 -check: all-it0.results all-it1.results all-it2.results - ! grep -v 'Success' $^ - -all-it0.results: $(addprefix build/,$(addsuffix .it0, $(TESTLIST))) build/builtincheckfalse.it0 - -rm -f $@ - cat test-input.txt | build/builtincheckfalse.it0 2> /dev/null 2>&1 | grep 'Success' - $(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; cat test-input.txt | ./build/$(test).it0 >> $@ ; echo "" >> $@ ;) - -all-it1.results: $(addprefix build/,$(addsuffix .it1, $(TESTLIST))) build/builtincheckfalse.it1 - -rm -f $@ - cat test-input.txt | build/builtincheckfalse.it1 2> /dev/null 2>&1 | grep 'Success' - $(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; cat test-input.txt | ./build/$(test).it1 >> $@ ; echo "" >> $@ ;) - -all-it2.results: $(addprefix build/,$(addsuffix .it2, $(TESTLIST))) build/builtincheckfalse.it2 - -rm -f $@ - cat test-input.txt | build/builtincheckfalse.it2 2> /dev/null 2>&1 | grep 'Success' - $(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; cat test-input.txt | ./build/$(test).it2 >> $@ ; echo "" >> $@ ;) +include Makefile.mk clean: - -rm -f *.results build/*.it0* build/*.it1* build/*.it2* + find build -name '*.c' -delete + find build -name '*.it0' -delete + find build -name '*.it0.result' -delete + find build -name '*.it0.stderr' -delete + find build -name '*.it0.stdout' -delete + find build -name '*.it1' -delete + find build -name '*.it1.result' -delete + find build -name '*.it1.stderr' -delete + find build -name '*.it1.stdout' -delete + find build -name '*.it2' -delete + find build -name '*.it2.result' -delete + find build -name '*.it2.stderr' -delete + find build -name '*.it2.stdout' -delete + find build -name '*.py' -delete + find build -name '*.tmp' -delete ### # it0 diff --git a/tests/build/.gitignore b/tests/build/test_builtins/.gitignore similarity index 51% rename from tests/build/.gitignore rename to tests/build/test_builtins/.gitignore index 4dfaadf..12ad130 100644 --- a/tests/build/.gitignore +++ b/tests/build/test_builtins/.gitignore @@ -3,12 +3,21 @@ /*.it0.o /*.it0.py /*.it0.py.tmp +/*.it0.result +/*.it0.stderr +/*.it0.stdout /*.it1 /*.it1.c /*.it1.o /*.it1.py /*.it1.py.tmp +/*.it1.result +/*.it1.stderr +/*.it1.stdout /*.it2 /*.it2.c /*.it2.c.tmp /*.it2.o +/*.it2.result +/*.it2.stderr +/*.it2.stdout diff --git a/tests/build/test_flow_control/.gitignore b/tests/build/test_flow_control/.gitignore new file mode 100644 index 0000000..12ad130 --- /dev/null +++ b/tests/build/test_flow_control/.gitignore @@ -0,0 +1,23 @@ +/*.it0 +/*.it0.c +/*.it0.o +/*.it0.py +/*.it0.py.tmp +/*.it0.result +/*.it0.stderr +/*.it0.stdout +/*.it1 +/*.it1.c +/*.it1.o +/*.it1.py +/*.it1.py.tmp +/*.it1.result +/*.it1.stderr +/*.it1.stdout +/*.it2 +/*.it2.c +/*.it2.c.tmp +/*.it2.o +/*.it2.result +/*.it2.stderr +/*.it2.stdout diff --git a/tests/build/test_parsing/.gitignore b/tests/build/test_parsing/.gitignore new file mode 100644 index 0000000..12ad130 --- /dev/null +++ b/tests/build/test_parsing/.gitignore @@ -0,0 +1,23 @@ +/*.it0 +/*.it0.c +/*.it0.o +/*.it0.py +/*.it0.py.tmp +/*.it0.result +/*.it0.stderr +/*.it0.stdout +/*.it1 +/*.it1.c +/*.it1.o +/*.it1.py +/*.it1.py.tmp +/*.it1.result +/*.it1.stderr +/*.it1.stdout +/*.it2 +/*.it2.c +/*.it2.c.tmp +/*.it2.o +/*.it2.result +/*.it2.stderr +/*.it2.stdout diff --git a/tests/build/test_stdlib_constants/.gitignore b/tests/build/test_stdlib_constants/.gitignore new file mode 100644 index 0000000..12ad130 --- /dev/null +++ b/tests/build/test_stdlib_constants/.gitignore @@ -0,0 +1,23 @@ +/*.it0 +/*.it0.c +/*.it0.o +/*.it0.py +/*.it0.py.tmp +/*.it0.result +/*.it0.stderr +/*.it0.stdout +/*.it1 +/*.it1.c +/*.it1.o +/*.it1.py +/*.it1.py.tmp +/*.it1.result +/*.it1.stderr +/*.it1.stdout +/*.it2 +/*.it2.c +/*.it2.c.tmp +/*.it2.o +/*.it2.result +/*.it2.stderr +/*.it2.stdout diff --git a/tests/build/test_stdlib_functions/.gitignore b/tests/build/test_stdlib_functions/.gitignore new file mode 100644 index 0000000..12ad130 --- /dev/null +++ b/tests/build/test_stdlib_functions/.gitignore @@ -0,0 +1,23 @@ +/*.it0 +/*.it0.c +/*.it0.o +/*.it0.py +/*.it0.py.tmp +/*.it0.result +/*.it0.stderr +/*.it0.stdout +/*.it1 +/*.it1.c +/*.it1.o +/*.it1.py +/*.it1.py.tmp +/*.it1.result +/*.it1.stderr +/*.it1.stdout +/*.it2 +/*.it2.c +/*.it2.c.tmp +/*.it2.o +/*.it2.result +/*.it2.stderr +/*.it2.stdout diff --git a/tests/build/test_variables/.gitignore b/tests/build/test_variables/.gitignore new file mode 100644 index 0000000..12ad130 --- /dev/null +++ b/tests/build/test_variables/.gitignore @@ -0,0 +1,23 @@ +/*.it0 +/*.it0.c +/*.it0.o +/*.it0.py +/*.it0.py.tmp +/*.it0.result +/*.it0.stderr +/*.it0.stdout +/*.it1 +/*.it1.c +/*.it1.o +/*.it1.py +/*.it1.py.tmp +/*.it1.result +/*.it1.stderr +/*.it1.stdout +/*.it2 +/*.it2.c +/*.it2.c.tmp +/*.it2.o +/*.it2.result +/*.it2.stderr +/*.it2.stdout diff --git a/tests/builtincheckfalse.lang0 b/tests/builtincheckfalse.lang0 deleted file mode 100644 index a433392..0000000 --- a/tests/builtincheckfalse.lang0 +++ /dev/null @@ -1,3 +0,0 @@ -main: - check not "1" : "Success" -/ diff --git a/tests/builtinchecktrue.lang0 b/tests/builtinchecktrue.lang0 deleted file mode 100644 index 3566241..0000000 --- a/tests/builtinchecktrue.lang0 +++ /dev/null @@ -1,4 +0,0 @@ -main: - check not "" : "Failure" - emit "Success" -/ diff --git a/tests/flowiffalse.lang0 b/tests/flowiffalse.lang0 deleted file mode 100644 index c17bf16..0000000 --- a/tests/flowiffalse.lang0 +++ /dev/null @@ -1,8 +0,0 @@ -main: - declare bool - set bool "" - if bool - return - / - emit "Success" -/ diff --git a/tests/flowiftrue.lang0 b/tests/flowiftrue.lang0 deleted file mode 100644 index 43dc7d5..0000000 --- a/tests/flowiftrue.lang0 +++ /dev/null @@ -1,7 +0,0 @@ -main: - declare bool - set bool "1" - if bool - emit "Success" - / -/ diff --git a/tests/flowreturnnothing.lang0 b/tests/flowreturnnothing.lang0 deleted file mode 100644 index d81523f..0000000 --- a/tests/flowreturnnothing.lang0 +++ /dev/null @@ -1,8 +0,0 @@ -func: - return -/ - -main: - func - emit "Success" -/ diff --git a/tests/flowreturnvalue.lang0 b/tests/flowreturnvalue.lang0 deleted file mode 100644 index 4846fe6..0000000 --- a/tests/flowreturnvalue.lang0 +++ /dev/null @@ -1,11 +0,0 @@ -func: - declare result - set result "Success" - return result -/ - -main: - declare result - calc result func - emit result -/ diff --git a/tests/flowreturnvalueconstant.lang0 b/tests/flowreturnvalueconstant.lang0 deleted file mode 100644 index 4c23208..0000000 --- a/tests/flowreturnvalueconstant.lang0 +++ /dev/null @@ -1,9 +0,0 @@ -func: - return "Success" -/ - -main: - declare result - calc result func - emit result -/ diff --git a/tests/generate-recipes.py b/tests/generate-recipes.py new file mode 100644 index 0000000..16e511a --- /dev/null +++ b/tests/generate-recipes.py @@ -0,0 +1,106 @@ +import glob +import os +import sys + +class Rule: + def __init__(self, target: str, prerequisites: list[str], recipe: list[str]) -> None: + self.target = target + self.prerequisites = prerequisites + self.recipe = recipe + + def make_lines(self): + return [ + self.target + ': ' + ' '.join(self.prerequisites), + ] + [ + '\t' + line + for line in self.recipe + ] + [''] + +def get_file_list(): + return sorted(glob.glob('test_*/*.lang0')) + +def make_rules(file_path, lang0it): + result: list[Rule] = [] + + stdin = file_path.replace('.lang0', '.stdin') + exp_stdout = file_path.replace('.lang0', '.exp.stdout') + exp_stderr = file_path.replace('.lang0', '.exp.stderr') + + act_result = 'build/' + file_path.replace('.lang0', f'.{lang0it}.result') + act_stderr = 'build/' + file_path.replace('.lang0', f'.{lang0it}.stderr') + act_stdout = 'build/' + file_path.replace('.lang0', f'.{lang0it}.stdout') + program = 'build/' + file_path.replace('.lang0', f'.{lang0it}') + + if os.path.isfile(exp_stdout) or os.path.isfile(exp_stderr): + result.append(Rule( + act_stdout, + [program] + ([stdin] if os.path.isfile(stdin) else []), + [ + '-' + (f'cat {stdin} | ' if os.path.isfile(stdin) else 'echo x | ') + + f'{program} 1> {act_stdout} 2> {act_stderr}', + ] + )) + + exp_list = [exp_stdout, exp_stderr] + act_list = [act_stdout, act_stderr] + + result.append(Rule( + act_result, + [act_stdout] + [ + x + for x in exp_list + if os.path.isfile(x) + ], + [ + 'rm -f $@', + ] + [ + f'-diff {exp_file} {act_file} >> $@' + for exp_file, act_file in zip(exp_list, act_list, strict=True) + if os.path.isfile(exp_file) + ] + [ + f'-diff /dev/null {act_file} >> $@' + for exp_file, act_file in zip(exp_list, act_list, strict=True) + if not os.path.isfile(exp_file) + ] + )) + + assert result[-1].prerequisites, f'Missing expectations for {file_path}' + + return result + +def main(program, write_to, *lang0it): + rule_list_list = [ + make_rules(file_path, it) + for file_path in get_file_list() + for it in lang0it + ] + + result_targets = [ + rule.target + for rule_list in rule_list_list + for rule in rule_list + if rule.target.endswith('.result') + ] + + rule_list_list.append([Rule( + 'verify-results', + result_targets, + [ + '@echo Finding failed test results...', + '@find $^ -not -empty -print -exec false {} +', + '@echo All tests passed.' + ] + )]) + + data = '\n'.join( + line + for rule_list in rule_list_list + for rule in rule_list + for line in rule.make_lines() + ) + + with open(write_to, 'wt', encoding='ASCII') as fil: + fil.write(data) + +if __name__ == '__main__': + main(*sys.argv) diff --git a/tests/parsingpredeclaredfunction0.lang0 b/tests/parsingpredeclaredfunction0.lang0 deleted file mode 100644 index bb15859..0000000 --- a/tests/parsingpredeclaredfunction0.lang0 +++ /dev/null @@ -1,10 +0,0 @@ -func/ - -main: - check func : "The function should return 1, even though it is not defined yet" - emit "Success" -/ - -func: - return "1" -/ diff --git a/tests/parsingpredeclaredfunction1.lang0 b/tests/parsingpredeclaredfunction1.lang0 deleted file mode 100644 index 743a6f6..0000000 --- a/tests/parsingpredeclaredfunction1.lang0 +++ /dev/null @@ -1,10 +0,0 @@ -func arg/ - -main: - check func "1" : "The function should return 1, even though it is not defined yet" - emit "Success" -/ - -func arg: - return arg -/ diff --git a/tests/stdinlineno.lang0 b/tests/stdinlineno.lang0 deleted file mode 100644 index 1f15ae9..0000000 --- a/tests/stdinlineno.lang0 +++ /dev/null @@ -1,86 +0,0 @@ -main: - declare char - declare colno - declare lineno - - calc char peek - calc colno stdincolno - calc lineno stdinlineno - check eq char "H" : "Read: H" char - check eq colno "1" : "The column number should not have advanced yet" colno - check eq lineno "1" : "The line number should not have advanced yet" lineno - skip - - calc char peek - calc colno stdincolno - calc lineno stdinlineno - check eq char "e" : "Read: e" char - check eq colno "2" : "The column number should have been advanced by 1" colno - check eq lineno "1" : "The line number should not have advanced yet" lineno - skip - - calc char peek - calc colno stdincolno - calc lineno stdinlineno - check eq char "l" : "Read: l" char - check eq colno "3" : "The column number should have been advanced by 2" colno - check eq lineno "1" : "The line number should not have advanced yet" lineno - skip - - calc char peek - calc colno stdincolno - calc lineno stdinlineno - check eq char "l" : "Read: l" char - check eq colno "4" : "The column number should have been advanced by 3" colno - check eq lineno "1" : "The line number should not have advanced yet" lineno - skip - - calc char peek - calc colno stdincolno - calc lineno stdinlineno - check eq char "o" : "Read: o" char - check eq colno "5" : "The column number should have been advanced by 4" colno - check eq lineno "1" : "The line number should not have advanced yet" lineno - skip - - calc char peek - calc colno stdincolno - calc lineno stdinlineno - check eq char "!" : "Read: !" char - check eq colno "6" : "The column number should have been advanced by 5" colno - check eq lineno "1" : "The line number should not have advanced yet" lineno - skip - - calc char peek - calc colno stdincolno - calc lineno stdinlineno - check eq char eol : "Read: eol" char - check eq colno "7" : "The column number should have been advanced by 6" colno - check eq lineno "1" : "The line number should not have advanced yet" lineno - skip - - calc char peek - calc colno stdincolno - calc lineno stdinlineno - check eq char eol : "Read: eol" char - check eq colno "1" : "The column number should have been reset" colno - check eq lineno "2" : "The line number should have advanced by 1" lineno - skip - - calc char peek - calc colno stdincolno - calc lineno stdinlineno - check eq char "T" : "Read: T" char - check eq colno "1" : "The column number should have been reset again" colno - check eq lineno "3" : "The line number should have advanced by 2" lineno - skip - - calc char peek - calc colno stdincolno - calc lineno stdinlineno - check eq char "h" : "Read: h" char - check eq colno "2" : "The line number should not have been advanced by 1" colno - check eq lineno "3" : "The line number should not have advanced further" lineno - - emit "Success" -/ diff --git a/tests/stdlibaddstringchar.lang0 b/tests/stdlibaddstringchar.lang0 deleted file mode 100644 index 991f778..0000000 --- a/tests/stdlibaddstringchar.lang0 +++ /dev/null @@ -1,6 +0,0 @@ -main: - declare result - calc result addstringchar "abc" "d" - check eq result "abcd" : "Adding abc and d should be abcd" - emit "Success" -/ diff --git a/tests/stdlibemit.lang0 b/tests/stdlibemit.lang0 deleted file mode 100644 index 26a5d02..0000000 --- a/tests/stdlibemit.lang0 +++ /dev/null @@ -1,3 +0,0 @@ -main: - emit "Success" -/ diff --git a/tests/stdlibeqfalse.lang0 b/tests/stdlibeqfalse.lang0 deleted file mode 100644 index 5c66e3c..0000000 --- a/tests/stdlibeqfalse.lang0 +++ /dev/null @@ -1,6 +0,0 @@ -main: - declare bool - calc bool eq "1" "2" - check not bool : "1 should not equal 2" - emit "Success" -/ diff --git a/tests/stdlibeqtrue.lang0 b/tests/stdlibeqtrue.lang0 deleted file mode 100644 index f495e10..0000000 --- a/tests/stdlibeqtrue.lang0 +++ /dev/null @@ -1,5 +0,0 @@ -main: - declare bool - check eq "1" "1" : "1 should equal 1" - emit "Success" -/ diff --git a/tests/stdlibltfalse.lang0 b/tests/stdlibltfalse.lang0 deleted file mode 100644 index 4963cfc..0000000 --- a/tests/stdlibltfalse.lang0 +++ /dev/null @@ -1,6 +0,0 @@ -main: - declare bool - calc bool lt "b" "a" - check not bool : "a should should sort before b" - emit "Success" -/ diff --git a/tests/stdliblttrue.lang0 b/tests/stdliblttrue.lang0 deleted file mode 100644 index 8c3ca69..0000000 --- a/tests/stdliblttrue.lang0 +++ /dev/null @@ -1,5 +0,0 @@ -main: - declare bool - check lt "a" "b" : "a should should sort before b" - emit "Success" -/ diff --git a/tests/stdlibpeek.lang0 b/tests/stdlibpeek.lang0 deleted file mode 100644 index 713f261..0000000 --- a/tests/stdlibpeek.lang0 +++ /dev/null @@ -1,6 +0,0 @@ -main: - declare char - calc char peek - check eq char "H" : "The first byte we're passed is expected to be an 'H'" - emit "Success" -/ diff --git a/tests/stdlibskip.lang0 b/tests/stdlibskip.lang0 deleted file mode 100644 index e6e4ae0..0000000 --- a/tests/stdlibskip.lang0 +++ /dev/null @@ -1,12 +0,0 @@ -main: - declare char - skip - calc char peek - check eq char "e" : "The second byte we're passed is expected to be an 'e'" - skip - skip - skip - calc char peek - check eq char "o" : "The fifth byte we're passed is expected to be an 'o'" - emit "Success" -/ diff --git a/tests/test-input.txt b/tests/test-input.txt deleted file mode 100644 index 37d8d0a..0000000 --- a/tests/test-input.txt +++ /dev/null @@ -1,3 +0,0 @@ -Hello! - -This is an example of standard input. diff --git a/tests/test_builtins/test_check.exp.stderr b/tests/test_builtins/test_check.exp.stderr new file mode 100644 index 0000000..88d98f0 --- /dev/null +++ b/tests/test_builtins/test_check.exp.stderr @@ -0,0 +1 @@ +ERROR: Check failed successfully diff --git a/tests/test_builtins/test_check.exp.stdout b/tests/test_builtins/test_check.exp.stdout new file mode 100644 index 0000000..7193c3d --- /dev/null +++ b/tests/test_builtins/test_check.exp.stdout @@ -0,0 +1 @@ +Still alive diff --git a/tests/test_builtins/test_check.lang0 b/tests/test_builtins/test_check.lang0 new file mode 100644 index 0000000..39b26ca --- /dev/null +++ b/tests/test_builtins/test_check.lang0 @@ -0,0 +1,8 @@ +main: + check not "" : "This should not trigger" + emit "Still alive" + emit eol + check not "1" : "Check failed successfully" + emit "This should not be output" + emit eol +/ diff --git a/tests/test_flow_control/test_break.exp.stdout b/tests/test_flow_control/test_break.exp.stdout new file mode 100644 index 0000000..51da420 --- /dev/null +++ b/tests/test_flow_control/test_break.exp.stdout @@ -0,0 +1 @@ +Success \ No newline at end of file diff --git a/tests/flowbreak.lang0 b/tests/test_flow_control/test_break.lang0 similarity index 51% rename from tests/flowbreak.lang0 rename to tests/test_flow_control/test_break.lang0 index 28afb05..f5f42ca 100644 --- a/tests/flowbreak.lang0 +++ b/tests/test_flow_control/test_break.lang0 @@ -1,6 +1,7 @@ main: forever + emit "Suc" break / - emit "Success" + emit "cess" / diff --git a/tests/test_flow_control/test_call.exp.stdout b/tests/test_flow_control/test_call.exp.stdout new file mode 100644 index 0000000..51da420 --- /dev/null +++ b/tests/test_flow_control/test_call.exp.stdout @@ -0,0 +1 @@ +Success \ No newline at end of file diff --git a/tests/flowcall.lang0 b/tests/test_flow_control/test_call.lang0 similarity index 100% rename from tests/flowcall.lang0 rename to tests/test_flow_control/test_call.lang0 diff --git a/tests/test_flow_control/test_if.exp.stdout b/tests/test_flow_control/test_if.exp.stdout new file mode 100644 index 0000000..25bf093 --- /dev/null +++ b/tests/test_flow_control/test_if.exp.stdout @@ -0,0 +1,2 @@ +1 is true +A is true diff --git a/tests/test_flow_control/test_if.lang0 b/tests/test_flow_control/test_if.lang0 new file mode 100644 index 0000000..9808b84 --- /dev/null +++ b/tests/test_flow_control/test_if.lang0 @@ -0,0 +1,18 @@ +main: + declare bool + set bool "" + if bool + emit "empty string is true" + emit eol + / + set bool "1" + if bool + emit "1 is true" + emit eol + / + set bool "A" + if bool + emit "A is true" + emit eol + / +/ diff --git a/tests/test_flow_control/test_return.exp.stdout b/tests/test_flow_control/test_return.exp.stdout new file mode 100644 index 0000000..3e6ebba --- /dev/null +++ b/tests/test_flow_control/test_return.exp.stdout @@ -0,0 +1,3 @@ +funca Constant +funcb Variable +funcc diff --git a/tests/test_flow_control/test_return.lang0 b/tests/test_flow_control/test_return.lang0 new file mode 100644 index 0000000..45ad294 --- /dev/null +++ b/tests/test_flow_control/test_return.lang0 @@ -0,0 +1,32 @@ +funca: + return "Constant" +/ + +funcb: + declare var + set var "Variable" + return var +/ + +funcc: + return +/ + +main: + declare var + + calc var funca + emit "funca " + emit var + emit eol + + calc var funcb + emit "funcb " + emit var + emit eol + + calc var funcc + emit "funcc " + emit var + emit eol +/ diff --git a/tests/test_parsing/test_predeclare_functions.exp.stdout b/tests/test_parsing/test_predeclare_functions.exp.stdout new file mode 100644 index 0000000..5bde10e --- /dev/null +++ b/tests/test_parsing/test_predeclare_functions.exp.stdout @@ -0,0 +1,2 @@ +Predeclared without argument: 1 +Predeclared with argument: 2 diff --git a/tests/test_parsing/test_predeclare_functions.lang0 b/tests/test_parsing/test_predeclare_functions.lang0 new file mode 100644 index 0000000..32b6926 --- /dev/null +++ b/tests/test_parsing/test_predeclare_functions.lang0 @@ -0,0 +1,24 @@ +funca/ +funcb arg/ + +main: + declare var + + calc var funca + emit "Predeclared without argument: " + emit var + emit eol + + calc var funcb "2" + emit "Predeclared with argument: " + emit var + emit eol +/ + +funca: + return "1" +/ + +funcb arg: + return arg +/ diff --git a/tests/test_stdlib_constants/test_eof.exp.stdout b/tests/test_stdlib_constants/test_eof.exp.stdout new file mode 100644 index 0000000..ce542ef --- /dev/null +++ b/tests/test_stdlib_constants/test_eof.exp.stdout @@ -0,0 +1 @@ +ÿ \ No newline at end of file diff --git a/tests/test_stdlib_constants/test_eof.lang0 b/tests/test_stdlib_constants/test_eof.lang0 new file mode 100644 index 0000000..85773bd --- /dev/null +++ b/tests/test_stdlib_constants/test_eof.lang0 @@ -0,0 +1,3 @@ +main: + emit eof +/ diff --git a/tests/test_stdlib_constants/test_eol.exp.stdout b/tests/test_stdlib_constants/test_eol.exp.stdout new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tests/test_stdlib_constants/test_eol.exp.stdout @@ -0,0 +1 @@ + diff --git a/tests/test_stdlib_constants/test_eol.lang0 b/tests/test_stdlib_constants/test_eol.lang0 new file mode 100644 index 0000000..7b085b0 --- /dev/null +++ b/tests/test_stdlib_constants/test_eol.lang0 @@ -0,0 +1,3 @@ +main: + emit eol +/ diff --git a/tests/test_stdlib_constants/test_quote.exp.stdout b/tests/test_stdlib_constants/test_quote.exp.stdout new file mode 100644 index 0000000..9d68933 --- /dev/null +++ b/tests/test_stdlib_constants/test_quote.exp.stdout @@ -0,0 +1 @@ +" \ No newline at end of file diff --git a/tests/test_stdlib_constants/test_quote.lang0 b/tests/test_stdlib_constants/test_quote.lang0 new file mode 100644 index 0000000..4bd5bfa --- /dev/null +++ b/tests/test_stdlib_constants/test_quote.lang0 @@ -0,0 +1,3 @@ +main: + emit quote +/ diff --git a/tests/test_stdlib_functions/test_add.exp.stdout b/tests/test_stdlib_functions/test_add.exp.stdout new file mode 100644 index 0000000..5c008eb --- /dev/null +++ b/tests/test_stdlib_functions/test_add.exp.stdout @@ -0,0 +1,3 @@ +1 + 2 = 12 +10 + 20 = 1020 +101 + 202 = 101202 diff --git a/tests/test_stdlib_functions/test_add.lang0 b/tests/test_stdlib_functions/test_add.lang0 new file mode 100644 index 0000000..0b63293 --- /dev/null +++ b/tests/test_stdlib_functions/test_add.lang0 @@ -0,0 +1,29 @@ +func tst a b: + declare var + calc var add a b + emit a + emit " + " + emit b + emit " = " + emit var + emit eol +/ + +main: + declare var + + calc var add "1" "2" + emit "1 + 2 = " + emit var + emit eol + + calc var add "10" "20" + emit "10 + 20 = " + emit var + emit eol + + calc var add "101" "202" + emit "101 + 202 = " + emit var + emit eol +/ diff --git a/tests/test_stdlib_functions/test_emit.exp.stdout b/tests/test_stdlib_functions/test_emit.exp.stdout new file mode 100644 index 0000000..5dd01c1 --- /dev/null +++ b/tests/test_stdlib_functions/test_emit.exp.stdout @@ -0,0 +1 @@ +Hello, world! \ No newline at end of file diff --git a/tests/test_stdlib_functions/test_emit.lang0 b/tests/test_stdlib_functions/test_emit.lang0 new file mode 100644 index 0000000..eec134b --- /dev/null +++ b/tests/test_stdlib_functions/test_emit.lang0 @@ -0,0 +1,4 @@ +main: + emit "Hello" + emit ", world!" +/ diff --git a/tests/test_stdlib_functions/test_eq.exp.stdout b/tests/test_stdlib_functions/test_eq.exp.stdout new file mode 100644 index 0000000..b8012a1 --- /dev/null +++ b/tests/test_stdlib_functions/test_eq.exp.stdout @@ -0,0 +1,4 @@ +eq A A: 1 +eq A B: +eq AA AA: 1 +eq AA AB: diff --git a/tests/test_stdlib_functions/test_eq.lang0 b/tests/test_stdlib_functions/test_eq.lang0 new file mode 100644 index 0000000..bdfc925 --- /dev/null +++ b/tests/test_stdlib_functions/test_eq.lang0 @@ -0,0 +1,19 @@ +main: + declare result + emit "eq A A: " + calc result eq "A" "A" + emit result + emit eol + emit "eq A B: " + calc result eq "A" "B" + emit result + emit eol + emit "eq AA AA: " + calc result eq "AA" "AA" + emit result + emit eol + emit "eq AA AB: " + calc result eq "AA" "AB" + emit result + emit eol +/ diff --git a/tests/test_stdlib_functions/test_lt.exp.stdout b/tests/test_stdlib_functions/test_lt.exp.stdout new file mode 100644 index 0000000..4457dd2 --- /dev/null +++ b/tests/test_stdlib_functions/test_lt.exp.stdout @@ -0,0 +1,6 @@ +lt A A: +lt A B: 1 +lt B A: +lt AA AA: +lt AA AB: 1 +lt AB AA: diff --git a/tests/test_stdlib_functions/test_lt.lang0 b/tests/test_stdlib_functions/test_lt.lang0 new file mode 100644 index 0000000..256618a --- /dev/null +++ b/tests/test_stdlib_functions/test_lt.lang0 @@ -0,0 +1,27 @@ +main: + declare result + emit "lt A A: " + calc result lt "A" "A" + emit result + emit eol + emit "lt A B: " + calc result lt "A" "B" + emit result + emit eol + emit "lt B A: " + calc result lt "B" "A" + emit result + emit eol + emit "lt AA AA: " + calc result lt "AA" "AA" + emit result + emit eol + emit "lt AA AB: " + calc result lt "AA" "AB" + emit result + emit eol + emit "lt AB AA: " + calc result lt "AB" "AA" + emit result + emit eol +/ diff --git a/tests/test_stdlib_functions/test_peek.exp.stdout b/tests/test_stdlib_functions/test_peek.exp.stdout new file mode 100644 index 0000000..43d88b6 --- /dev/null +++ b/tests/test_stdlib_functions/test_peek.exp.stdout @@ -0,0 +1 @@ +AAA \ No newline at end of file diff --git a/tests/test_stdlib_functions/test_peek.lang0 b/tests/test_stdlib_functions/test_peek.lang0 new file mode 100644 index 0000000..70ec0eb --- /dev/null +++ b/tests/test_stdlib_functions/test_peek.lang0 @@ -0,0 +1,9 @@ +main: + declare char + calc char peek + emit char + calc char peek + emit char + calc char peek + emit char +/ diff --git a/tests/test_stdlib_functions/test_peek.stdin b/tests/test_stdlib_functions/test_peek.stdin new file mode 100644 index 0000000..48b83b8 --- /dev/null +++ b/tests/test_stdlib_functions/test_peek.stdin @@ -0,0 +1 @@ +ABC \ No newline at end of file diff --git a/tests/test_stdlib_functions/test_skip.exp.stdout b/tests/test_stdlib_functions/test_skip.exp.stdout new file mode 100644 index 0000000..a8d7cff --- /dev/null +++ b/tests/test_stdlib_functions/test_skip.exp.stdout @@ -0,0 +1 @@ +ABD \ No newline at end of file diff --git a/tests/test_stdlib_functions/test_skip.lang0 b/tests/test_stdlib_functions/test_skip.lang0 new file mode 100644 index 0000000..485e918 --- /dev/null +++ b/tests/test_stdlib_functions/test_skip.lang0 @@ -0,0 +1,12 @@ +main: + declare char + calc char peek + emit char + skip + calc char peek + emit char + skip + skip + calc char peek + emit char +/ diff --git a/tests/test_stdlib_functions/test_skip.stdin b/tests/test_stdlib_functions/test_skip.stdin new file mode 100644 index 0000000..a6bddc4 --- /dev/null +++ b/tests/test_stdlib_functions/test_skip.stdin @@ -0,0 +1 @@ +ABCD \ No newline at end of file diff --git a/tests/test_stdlib_functions/test_stdincolno.exp.stdout b/tests/test_stdlib_functions/test_stdincolno.exp.stdout new file mode 100644 index 0000000..2d6f286 --- /dev/null +++ b/tests/test_stdlib_functions/test_stdincolno.exp.stdout @@ -0,0 +1,4 @@ +"A" 1 +" +" 2 +"B" 1 diff --git a/tests/test_stdlib_functions/test_stdincolno.lang0 b/tests/test_stdlib_functions/test_stdincolno.lang0 new file mode 100644 index 0000000..9ab893f --- /dev/null +++ b/tests/test_stdlib_functions/test_stdincolno.lang0 @@ -0,0 +1,35 @@ +main: + declare char + declare colno + + calc char peek + calc colno stdincolno + emit quote + emit char + emit quote + emit " " + emit colno + emit eol + + skip + + calc char peek + calc colno stdincolno + emit quote + emit char + emit quote + emit " " + emit colno + emit eol + + skip + + calc char peek + calc colno stdincolno + emit quote + emit char + emit quote + emit " " + emit colno + emit eol +/ diff --git a/tests/test_stdlib_functions/test_stdincolno.stdin b/tests/test_stdlib_functions/test_stdincolno.stdin new file mode 100644 index 0000000..b1e6722 --- /dev/null +++ b/tests/test_stdlib_functions/test_stdincolno.stdin @@ -0,0 +1,3 @@ +A +B +C diff --git a/tests/test_stdlib_functions/test_stdinlineno.exp.stdout b/tests/test_stdlib_functions/test_stdinlineno.exp.stdout new file mode 100644 index 0000000..eec4c50 --- /dev/null +++ b/tests/test_stdlib_functions/test_stdinlineno.exp.stdout @@ -0,0 +1,4 @@ +"A" 1 +" +" 1 +"B" 2 diff --git a/tests/test_stdlib_functions/test_stdinlineno.lang0 b/tests/test_stdlib_functions/test_stdinlineno.lang0 new file mode 100644 index 0000000..8109c36 --- /dev/null +++ b/tests/test_stdlib_functions/test_stdinlineno.lang0 @@ -0,0 +1,35 @@ +main: + declare char + declare lineno + + calc char peek + calc lineno stdinlineno + emit quote + emit char + emit quote + emit " " + emit lineno + emit eol + + skip + + calc char peek + calc lineno stdinlineno + emit quote + emit char + emit quote + emit " " + emit lineno + emit eol + + skip + + calc char peek + calc lineno stdinlineno + emit quote + emit char + emit quote + emit " " + emit lineno + emit eol +/ diff --git a/tests/test_stdlib_functions/test_stdinlineno.stdin b/tests/test_stdlib_functions/test_stdinlineno.stdin new file mode 100644 index 0000000..b1e6722 --- /dev/null +++ b/tests/test_stdlib_functions/test_stdinlineno.stdin @@ -0,0 +1,3 @@ +A +B +C diff --git a/tests/test_variables/test_calc.exp.stdout b/tests/test_variables/test_calc.exp.stdout new file mode 100644 index 0000000..51da420 --- /dev/null +++ b/tests/test_variables/test_calc.exp.stdout @@ -0,0 +1 @@ +Success \ No newline at end of file diff --git a/tests/variablescalc.lang0 b/tests/test_variables/test_calc.lang0 similarity index 100% rename from tests/variablescalc.lang0 rename to tests/test_variables/test_calc.lang0 diff --git a/tests/test_variables/test_set.exp.stdout b/tests/test_variables/test_set.exp.stdout new file mode 100644 index 0000000..51da420 --- /dev/null +++ b/tests/test_variables/test_set.exp.stdout @@ -0,0 +1 @@ +Success \ No newline at end of file diff --git a/tests/variablesset.lang0 b/tests/test_variables/test_set.lang0 similarity index 100% rename from tests/variablesset.lang0 rename to tests/test_variables/test_set.lang0