This commit is contained in:
2026-04-25 22:03:30 +02:00
parent ff1c392dd6
commit d2d09c770d
20 changed files with 782 additions and 16 deletions

View File

@@ -8,7 +8,7 @@ from tests._helpers import (
String, TemptaStatement, UnaryMinus, UnaryNot, Fractio, frac_to_fraction,
fraction_to_frac, num_to_int, int_to_num, make_string,
ValInt, ValStr, ValBool, ValList, ValDict, ValNul, ValFunc, ValFrac,
CentvrionError, _RUNTIME_C, _cent_rng,
CentvrionError, _RUNTIME_C, _IASON_C, _cent_rng,
Lexer, Parser, compile_program,
os, subprocess, tempfile, StringIO, patch,
)
@@ -160,6 +160,24 @@ error_tests = [
('IVNGE(["a"], II)', CentvrionError), # IVNGE second arg not a list
("IVNGE([VERITAS], [I])", CentvrionError), # IVNGE invalid key type (bool)
("IVNGE([[I]], [II])", CentvrionError), # IVNGE invalid key type (list)
("IASON_LEGE('null')", CentvrionError), # IASON module required for IASON_LEGE
("IASON_SCRIBE(NVLLVS)", CentvrionError), # IASON module required for IASON_SCRIBE
("CVM IASON\nIASON_LEGE(I)", CentvrionError), # IASON_LEGE non-string arg
("CVM IASON\nIASON_LEGE()", CentvrionError), # IASON_LEGE no args
("CVM IASON\nIASON_LEGE('null', 'null')", CentvrionError), # IASON_LEGE too many args
("CVM IASON\nIASON_LEGE('not json')", CentvrionError), # invalid JSON
("CVM IASON\nIASON_LEGE('[1,]')", CentvrionError), # trailing comma in array
("CVM IASON\nIASON_LEGE('{\"a\":}')", CentvrionError), # missing value in object
("CVM IASON\nIASON_LEGE('{\"a\" 1}')", CentvrionError), # missing colon in object
("CVM IASON\nIASON_LEGE('[1, 2')", CentvrionError), # unterminated array
("CVM IASON\nIASON_LEGE('{')", CentvrionError), # unterminated object
("CVM IASON\nIASON_LEGE('\"abc')", CentvrionError), # unterminated string
("CVM IASON\nIASON_LEGE('[1] junk')", CentvrionError), # trailing data
("CVM IASON\nIASON_LEGE('[\"a\\\\x\"]')", CentvrionError), # invalid escape
("CVM IASON\nIASON_SCRIBE()", CentvrionError), # IASON_SCRIBE no args
("CVM IASON\nIASON_SCRIBE(I, II)", CentvrionError), # IASON_SCRIBE too many args
('CVM IASON\nIASON_SCRIBE(IVNGE([I], ["v"]))', CentvrionError), # IASON_SCRIBE int dict keys
("CVM IASON\nIASON_SCRIBE(FVNCTIO (x) VT { REDI(x) })", CentvrionError), # IASON_SCRIBE function
]
class TestErrors(unittest.TestCase):
@@ -196,7 +214,7 @@ class TestErrorLineNumbers(unittest.TestCase):
tmp_bin_path = tmp_bin.name
try:
subprocess.run(
["gcc", "-O2", tmp_c_path, _RUNTIME_C, "-o", tmp_bin_path, "-lcurl", "-lmicrohttpd"],
["gcc", "-O2", tmp_c_path, _RUNTIME_C, _IASON_C, "-o", tmp_bin_path, "-lcurl", "-lmicrohttpd", "-lm"],
check=True, capture_output=True,
)
proc = subprocess.run([tmp_bin_path], capture_output=True, text=True)