Skip to content

Commit 20f5f82

Browse files
author
whitequark
committedJul 23, 2015
Make sure tests pass both on ARTIQ Python and CPython.
In some cases (the `is` operator and wraparound arithmetics) the tests will only pass on ARTIQ Python. These are conditionally commented out.
·
8.01.0rc1
1 parent 65121b4 commit 20f5f82

File tree

16 files changed

+34
-12
lines changed

16 files changed

+34
-12
lines changed
 

‎artiq/compiler/testbench/jit.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ def process_diagnostic(diag):
1818
engine = diagnostic.Engine()
1919
engine.process = process_diagnostic
2020

21-
llmod = Module.from_string("".join(fileinput.input()).expandtabs(), engine=engine).llvm_ir
21+
source = "".join(fileinput.input())
22+
source = source.replace("#ARTIQ#", "")
23+
llmod = Module.from_string(source.expandtabs(), engine=engine).llvm_ir
2224

2325
lltarget = llvm.Target.from_default_triple()
2426
llmachine = lltarget.create_target_machine()

‎lit-test/compiler/integration/arithmetics.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
assert -(-1) == 1
45
assert -(-1.0) == 1.0
@@ -28,7 +29,7 @@
2829
assert 1 << 1 == 2
2930
assert 2 >> 1 == 1
3031
assert -2 >> 1 == -1
31-
assert 1 << 32 == 0
32+
#ARTIQ#assert 1 << 32 == 0
3233
assert -1 >> 32 == -1
3334
assert 0x18 & 0x0f == 0x08
3435
assert 0x18 | 0x0f == 0x1f

‎lit-test/compiler/integration/attribute.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
r = range(10)
45
assert r.start == 0

‎lit-test/compiler/integration/bool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
assert (not 0) == True
45
assert (not 1) == False
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
assert bool() is False
45
# bool(x) is tested in bool.py
56

67
assert int() is 0
78
assert int(1.0) is 1
8-
assert int(1, width=64) << 40 is 1099511627776
9+
#ARTIQ#assert int(1, width=64) << 40 is 1099511627776
910

10-
assert float() is 0.0
11-
assert float(1) is 1.0
11+
#ARTIQ#assert float() is 0.0
12+
#ARTIQ#assert float(1) is 1.0
1213

1314
x = list()
1415
if False: x = [1]
1516
assert x == []
1617

17-
assert range(10) is range(0, 10, 1)
18-
assert range(1, 10) is range(1, 10, 1)
18+
#ARTIQ#assert range(10) is range(0, 10, 1)
19+
#ARTIQ#assert range(1, 10) is range(1, 10, 1)
1920

2021
assert len([1, 2, 3]) is 3
2122
assert len(range(10)) is 10
2223
assert len(range(0, 10, 2)) is 5
2324

24-
assert round(1.4) is 1 and round(1.6) is 2
25+
#ARTIQ#assert round(1.4) is 1 and round(1.6) is 2

‎lit-test/compiler/integration/compare.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
assert 1 < 2 and not (2 < 1)
45
assert 2 > 1 and not (1 > 2)
@@ -11,7 +12,7 @@
1112

1213
x, y = [1], [1]
1314
assert x is x and x is not y
14-
assert range(10) is range(10) and range(10) is not range(11)
15+
#ARTIQ#assert range(10) is range(10) and range(10) is not range(11)
1516

1617
lst = [1, 2, 3]
1718
assert 1 in lst and 0 not in lst

‎lit-test/compiler/integration/for.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
count = 0
45
for x in range(10):

‎lit-test/compiler/integration/function.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
def fib(x):
45
if x == 1:

‎lit-test/compiler/integration/if.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
if True:
45
assert True

‎lit-test/compiler/integration/lambda.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
assert (lambda: 1)() == 1
45
assert (lambda x: x)(1) == 1

‎lit-test/compiler/integration/list.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
[x, y] = [1, 2]
45
assert (x, y) == (1, 2)

‎lit-test/compiler/integration/locals.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
x = 1
45
assert x == 1

‎lit-test/compiler/integration/subscript.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
lst = list(range(10))
45
assert lst[0] == 0

‎lit-test/compiler/integration/tuple.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
x, y = 2, 1
45
x, y = y, x

‎lit-test/compiler/integration/while.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: %python -m artiq.compiler.testbench.jit %s
2+
# RUN: %python %s
23

34
cond, count = True, 0
45
while cond:

‎lit-test/harness.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import sys, os, argparse, importlib
1313

1414
parser = argparse.ArgumentParser(description=__doc__)
15-
parser.add_argument('-m', metavar='mod', type=str, required=True,
15+
parser.add_argument('-m', metavar='mod', type=str,
1616
help='run library module as a script')
1717
parser.add_argument('args', type=str, nargs='+',
1818
help='arguments passed to program in sys.argv[1:]')
@@ -21,5 +21,11 @@
2121
artiq_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
2222
sys.path.insert(1, artiq_path)
2323

24-
sys.argv[1:] = args.args
25-
importlib.import_module(args.m).main()
24+
if args.m:
25+
sys.argv[1:] = args.args
26+
importlib.import_module(args.m).main()
27+
else:
28+
sys.argv[1:] = args.args[1:]
29+
with open(args.args[0]) as f:
30+
code = compile(f.read(), args.args[0], 'exec')
31+
exec(code)

0 commit comments

Comments
 (0)
Please sign in to comment.