Commit ecce2700 authored by Ondrasek Timotej's avatar Ondrasek Timotej
Browse files

logic

parent 3279dcbe
Loading
Loading
Loading
Loading
+62 −0
Original line number Diff line number Diff line
{
    "collection_name": "Logic tests",
    "path": ["game", "test_scripts", "logic"],
    "tests": [
        {
            "name": "And (true && true)",
            "function": "and",
            "input": [["BOOL", true], ["BOOL", true]],
            "output": ["BOOL", true],
            "log": []
        },
        {
            "name": "And (true && false)",
            "function": "and",
            "input": [["BOOL", true], ["BOOL", false]],
            "output": ["BOOL", false],
            "log": []
        },
        {
            "name": "And (false && false)",
            "function": "and",
            "input": [["BOOL", false], ["BOOL", false]],
            "output": ["BOOL", false],
            "log": []
        },
        {
            "name": "Or (true || true)",
            "function": "or",
            "input": [["BOOL", true], ["BOOL", true]],
            "output": ["BOOL", true],
            "log": []
        },
        {
            "name": "Or (true || false)",
            "function": "or",
            "input": [["BOOL", true], ["BOOL", false]],
            "output": ["BOOL", true],
            "log": []
        },
        {
            "name": "Or (false || false)",
            "function": "or",
            "input": [["BOOL", false], ["BOOL", false]],
            "output": ["BOOL", false],
            "log": []
        },
        {
            "name": "Not true",
            "function": "not",
            "input": [["BOOL", true]],
            "output": ["BOOL", false],
            "log": []
        },
        {
            "name": "Not false",
            "function": "not",
            "input": [["BOOL", false]],
            "output": ["BOOL", true],
            "log": []
        }
    ]
}
 No newline at end of file
+77 −0
Original line number Diff line number Diff line
{
    "constants": [
    ],
    "static": [
    ],
    "functions": [
        {
            "name": "__static_init__",
            "params": [
            ],
            "returns": false,
            "locals": [
            ],
            "code": [
                [
                    ["RET", "", [0, 0]]
                ]
            ]
        },
        {
            "name": "and",
            "params": [
                "BOOL",
                "BOOL",
                "BOOL"
            ],
            "returns": true,
            "locals": [
                "BOOL"
            ],
            "code": [
                [
                    ["AND", "lpp", 0, 1, 2, [3, 12]],
                    ["COPY_VAL_BOOL", "pl", 0, 0, [3, 5]],
                    ["RET", "", [3, 5]]
                ]
            ]
        },
        {
            "name": "or",
            "params": [
                "BOOL",
                "BOOL",
                "BOOL"
            ],
            "returns": true,
            "locals": [
                "BOOL"
            ],
            "code": [
                [
                    ["OR", "lpp", 0, 1, 2, [8, 12]],
                    ["COPY_VAL_BOOL", "pl", 0, 0, [8, 5]],
                    ["RET", "", [8, 5]]
                ]
            ]
        },
        {
            "name": "not",
            "params": [
                "BOOL",
                "BOOL"
            ],
            "returns": true,
            "locals": [
                "BOOL"
            ],
            "code": [
                [
                    ["NOT", "lp", 0, 1, [13, 12]],
                    ["COPY_VAL_BOOL", "pl", 0, 0, [13, 5]],
                    ["RET", "", [13, 5]]
                ]
            ]
        }
    ]
}
 No newline at end of file
+14 −0
Original line number Diff line number Diff line
fn and(a: bool, b: bool) -> bool
{
    return a && b;
}

fn or(a: bool, b: bool) -> bool
{
    return a || b;
}

fn not(a: bool) -> bool
{
    return !a;
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ Tester::Tester()
    , scripts_path{ "tests", "scripts", "bytecode" }
    , test_data_path{ "tests", "metadata" }
    , collection_names{ "cast", "new", "get_set", "copy", "add", "sub", "mul", "div", "mod", 
        "eq", "ne", "lt", "le", "gt", "ge" }
        "eq", "ne", "lt", "le", "gt", "ge", "logic" }
    //, collection_names{ "lt", "le", "gt", "ge" }
{}