tests/mock: move mock to dedicated file, and add several mock entries
This commit is contained in:
parent
b27faf974f
commit
368629caa5
3 changed files with 33 additions and 18 deletions
|
|
@ -28,31 +28,19 @@ class REPLInput(io.TextIOWrapper):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("--mock", action="store_true", help="Use default test input")
|
parser.add_argument("--mock", action="store_true", help="Use test input")
|
||||||
|
|
||||||
|
valid_mock_inputs = list(filter(lambda x: x[0] != "_", dir(mock)))
|
||||||
|
parser.add_argument("--mock-input", dest="mock_input", type=str, choices=valid_mock_inputs, default="legacy_mock",
|
||||||
|
help="Specify mock input")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
data = """
|
|
||||||
{
|
|
||||||
// let byte: uint32 = 42;
|
|
||||||
}
|
|
||||||
let byte: uint32;
|
|
||||||
|
|
||||||
2 + 8 - 1 * (byte = 3 + 5)
|
|
||||||
/ (byte = 255) + byte;
|
|
||||||
byte = byte + byte;
|
|
||||||
{
|
|
||||||
// let a: uint32 = byte;
|
|
||||||
}
|
|
||||||
// { let b: uint32; }
|
|
||||||
display(byte, 3) + 1;
|
|
||||||
"""
|
|
||||||
|
|
||||||
_input_stream = REPLInput()
|
_input_stream = REPLInput()
|
||||||
|
|
||||||
if args.mock:
|
if args.mock:
|
||||||
|
data = getattr(mock, args.mock_input)
|
||||||
print("Source:\n", data)
|
print("Source:\n", data)
|
||||||
input_stream = io.StringIO(data)
|
|
||||||
_input_stream = io.StringIO(data)
|
_input_stream = io.StringIO(data)
|
||||||
|
|
||||||
input_stream = TextIOWithMemory(_input_stream)
|
input_stream = TextIOWithMemory(_input_stream)
|
||||||
|
|
|
||||||
1
compiler/tests/__init__.py
Normal file
1
compiler/tests/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from . import mock
|
||||||
26
compiler/tests/mock.py
Normal file
26
compiler/tests/mock.py
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
simple_arithmetic = "1+1;"
|
||||||
|
|
||||||
|
display_integer = "display(42);"
|
||||||
|
|
||||||
|
missing_colon = "display(42)"
|
||||||
|
|
||||||
|
legacy_mock = """
|
||||||
|
{
|
||||||
|
let byte: uint32 = 42;
|
||||||
|
}
|
||||||
|
let byte: uint32;
|
||||||
|
let foo: uint32;
|
||||||
|
|
||||||
|
byte = 4;
|
||||||
|
// 10 - (4 / 3) + 4 = 13
|
||||||
|
2 + 8 - 1 * byte / (foo = 3) + byte;
|
||||||
|
|
||||||
|
// byte = 13 + 13 = 26
|
||||||
|
byte = byte + byte;
|
||||||
|
{
|
||||||
|
//let a: uint32 = byte;
|
||||||
|
}
|
||||||
|
// { let b: uint32; }
|
||||||
|
// let display: uint32 = 3;
|
||||||
|
display(byte, 3) + 1;
|
||||||
|
"""
|
||||||
Loading…
Add table
Add a link
Reference in a new issue