🐐 NVMERVS
This commit is contained in:
27
tests.py
27
tests.py
@@ -638,6 +638,14 @@ builtin_tests = [
|
||||
('SVBSTITVE("(a)(b)", "\\2\\1", "ab")', Program([], [ExpressionStatement(BuiltIn("SVBSTITVE", [String("(a)(b)"), String("\\2\\1"), String("ab")]))]), ValStr("ba")),
|
||||
# SVBSTITVE: backreference with unmatched group (ignored)
|
||||
('SVBSTITVE("(a)(b)?", "\\1\\2", "a")', Program([], [ExpressionStatement(BuiltIn("SVBSTITVE", [String("(a)(b)?"), String("\\1\\2"), String("a")]))]), ValStr("a")),
|
||||
# NVMERVS: basic conversion
|
||||
('NVMERVS("XIV")', Program([], [ExpressionStatement(BuiltIn("NVMERVS", [String("XIV")]))]), ValInt(14)),
|
||||
# NVMERVS: simple single numeral
|
||||
('NVMERVS("I")', Program([], [ExpressionStatement(BuiltIn("NVMERVS", [String("I")]))]), ValInt(1)),
|
||||
# NVMERVS: large numeral
|
||||
('NVMERVS("MMMCMXCIX")', Program([], [ExpressionStatement(BuiltIn("NVMERVS", [String("MMMCMXCIX")]))]), ValInt(3999)),
|
||||
# NVMERVS: subtractive form
|
||||
('NVMERVS("IX")', Program([], [ExpressionStatement(BuiltIn("NVMERVS", [String("IX")]))]), ValInt(9)),
|
||||
# SCINDE: basic split
|
||||
('SCINDE("a,b,c", ",")', Program([], [ExpressionStatement(BuiltIn("SCINDE", [String("a,b,c"), String(",")]))]), ValList([ValStr("a"), ValStr("b"), ValStr("c")])),
|
||||
# SCINDE: no match (delimiter not found)
|
||||
@@ -668,6 +676,9 @@ error_tests = [
|
||||
("DIC(M + M + M + M)", CentvrionError), # output > 3999 without MAGNVM
|
||||
("IIII", CentvrionError), # invalid Roman numeral in source
|
||||
("FORTVITVS_NVMERVS(I, X)", CentvrionError), # requires FORS module
|
||||
('NVMERVS(I)', CentvrionError), # NVMERVS expects a string, not int
|
||||
('NVMERVS("ABC")', CentvrionError), # invalid Roman numeral string
|
||||
('NVMERVS("XIV", "IX")', CentvrionError), # too many args
|
||||
("DEFINI f (x) VT { REDI(x) }\nINVOCA f (I, II)", CentvrionError), # too many args
|
||||
("DEFINI f (x, y) VT { REDI(x) }\nINVOCA f (I)", CentvrionError), # too few args
|
||||
("DEFINI f () VT { REDI(I) }\nINVOCA f (I)", CentvrionError), # args to zero-param function
|
||||
@@ -2236,6 +2247,22 @@ dict_tests = [
|
||||
('TABVLA {"x" VT I + II}',
|
||||
Program([], [ExpressionStatement(DataDict([(String("x"), BinOp(Numeral("I"), Numeral("II"), "SYMBOL_PLUS"))]))]),
|
||||
ValDict({"x": ValInt(3)})),
|
||||
# empty dict with newline
|
||||
('TABVLA {\n}',
|
||||
Program([], [ExpressionStatement(DataDict([]))]),
|
||||
ValDict({})),
|
||||
# single entry with surrounding newlines
|
||||
('TABVLA {\n"a" VT I\n}',
|
||||
Program([], [ExpressionStatement(DataDict([(String("a"), Numeral("I"))]))]),
|
||||
ValDict({"a": ValInt(1)})),
|
||||
# multiple entries with newlines after commas
|
||||
('TABVLA {\n"a" VT I,\n"b" VT II\n}',
|
||||
Program([], [ExpressionStatement(DataDict([(String("a"), Numeral("I")), (String("b"), Numeral("II"))]))]),
|
||||
ValDict({"a": ValInt(1), "b": ValInt(2)})),
|
||||
# newlines around every delimiter
|
||||
('TABVLA {\n"a" VT I,\n"b" VT II,\n"c" VT III\n}',
|
||||
Program([], [ExpressionStatement(DataDict([(String("a"), Numeral("I")), (String("b"), Numeral("II")), (String("c"), Numeral("III"))]))]),
|
||||
ValDict({"a": ValInt(1), "b": ValInt(2), "c": ValInt(3)})),
|
||||
]
|
||||
|
||||
class TestDict(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user