Skip to content

Commit 1f5e9ab

Browse files
authored
Add running of integration tests and fix some issues (#67)
2 parents 20c17ad + 392087b commit 1f5e9ab

File tree

12 files changed

+228
-40
lines changed

12 files changed

+228
-40
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- name: Basics Python 3.13
2424
python-version: 3.13
2525
id: basic
26+
python-type: cpython
2627

2728
steps:
2829
- name: Checkout
@@ -52,8 +53,8 @@ jobs:
5253
run: |
5354
export PYTHON=python
5455
export PYTHONPATH=src
55-
SOM_INTERP=AST pytest
56-
SOM_INTERP=BC pytest
56+
SOM_INTERP=AST pytest tests
57+
SOM_INTERP=BC pytest tests
5758
SOM_INTERP=AST ./som.sh -cp Smalltalk TestSuite/TestHarness.som
5859
SOM_INTERP=BC ./som.sh -cp Smalltalk TestSuite/TestHarness.som
5960
echo "[system exit: 0] value" | SOM_INTERP=AST ./som.sh -cp Smalltalk
@@ -63,11 +64,24 @@ jobs:
6364
if: matrix.id != 'basic'
6465
run: |
6566
export SOM_INTERP=${{ matrix.interp }}
66-
PYTHONPATH=$PYTHONPATH:.pypy:src pytest
67+
PYTHONPATH=$PYTHONPATH:.pypy:src pytest tests
6768
PYTHONPATH=$PYTHONPATH:.pypy ./som.sh -cp Smalltalk TestSuite/TestHarness.som
6869
PYTHONPATH=$PYTHONPATH:.pypy .pypy/rpython/bin/rpython --batch src/main_rpython.py
6970
./som-${{ matrix.id }}-interp -cp Smalltalk TestSuite/TestHarness.som
7071
72+
- name: Integration Tests
73+
if: matrix.python-type == 'cpython'
74+
run: |
75+
pip install pyyaml
76+
export VM=./som.sh
77+
export CLASSPATH=Smalltalk
78+
export TEST_EXPECTATIONS=./integration-tests.yml
79+
export AWFY=Examples/AreWeFastYet/Core
80+
81+
export PYTHON=python
82+
SOM_INTERP=AST pytest core-lib/IntegrationTests
83+
SOM_INTERP=BC pytest core-lib/IntegrationTests
84+
7185
- name: SomSom Tests
7286
if: matrix.id != 'basic'
7387
run: |
@@ -78,13 +92,13 @@ jobs:
7892
run: |
7993
pip install black
8094
black --check --diff src tests
81-
if: matrix.python-version == '3.11'
95+
if: matrix.python-type == 'cpython'
8296

8397
- name: Install and Run PyLint
8498
run: |
8599
pip install pylint
86100
pylint --init-hook="import sys; sys.setrecursionlimit(2000)" src tests
87-
if: matrix.python-version == '3.11'
101+
if: matrix.python-type == 'cpython'
88102

89103

90104
concurrency:

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ build-and-test-interpreters:
5656
- (cd Examples/Benchmarks/TestSuite && ./duplicate-tests.sh)
5757

5858
# Unit Tests
59-
- PYTHONPATH=src python3 -m pytest
59+
- PYTHONPATH=src python3 -m pytest tests
6060
- ./som.sh -cp Smalltalk TestSuite/TestHarness.som
6161

6262
# Interpreter
@@ -67,7 +67,7 @@ build-and-test-interpreters:
6767
- export SOM_INTERP=AST
6868

6969
# Unit Tests
70-
- PYTHONPATH=src python3 -m pytest
70+
- PYTHONPATH=src python3 -m pytest tests
7171
- ./som.sh -cp Smalltalk TestSuite/TestHarness.som
7272

7373
# Interpreter

.pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ disable=raw-checker-failed,
8282
useless-object-inheritance,
8383
too-few-public-methods,
8484
too-many-arguments,
85+
too-many-positional-arguments,
8586
too-many-function-args,
8687
too-many-locals,
8788
too-many-instance-attributes,

core-lib

Submodule core-lib updated 252 files

integration-tests.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
known_failures: []
2+
3+
4+
failing_as_unspecified:
5+
- Tests/arbint_double_div_err.som
6+
- Tests/arbint_double_div_zero_err.som
7+
- Tests/arbint_modulus_err.som
8+
- Tests/array_at_idx0_err.som
9+
- Tests/array_at_idx2_err.som
10+
- Tests/array_at_idx_err.som
11+
- Tests/array_at_negative_idx_err.som
12+
- Tests/array_at_put_idx0_err.som
13+
- Tests/array_at_put_idx2_err.som
14+
- Tests/call2.som
15+
16+
# I think this one is about E vs e, but maybe also double rendering
17+
- Tests/double2.som
18+
# - Tests/double_double_div.som
19+
# - Tests/int_double_div.som
20+
- Tests/integer_asdouble.som
21+
22+
# precision printing issues
23+
- Tests/double1.som
24+
25+
# I think IEEE allows for infinities here, and we probably want that
26+
- Tests/double3.som
27+
- Tests/double4.som
28+
- Tests/double5.som
29+
- Tests/double6.som
30+
- Tests/double7.som
31+
- Tests/double8.som
32+
- Tests/double9.som
33+
- Tests/double11.som
34+
- Tests/double13.som
35+
36+
# Java seems to do some rounding in the transition, but it's also requiring bigints
37+
# - Tests/double_asinteger.som
38+
39+
# computes slightly different values
40+
- Tests/double_double_div.som
41+
42+
- Tests/double_double_div_err.som
43+
- Tests/double_double_div_zero_err1.som
44+
- Tests/double_double_div_zero_err2.som
45+
- Tests/double_double_div_zero_err3.som
46+
- Tests/double_double_div_zero_err4.som
47+
- Tests/double_modulus.som
48+
- Tests/double_modulus_err.som
49+
50+
- Tests/exit_double.som
51+
- Tests/exit_int_too_big.som
52+
- Tests/exit_string.som
53+
54+
- Tests/fromstring_double_err.som
55+
- Tests/fromstring_err.som
56+
57+
# #methods returns an array, but it should be specified as not being
58+
# the same array, so, it won't have the same hashcode:
59+
- Tests/hashcode.som
60+
- Tests/hashcode2.som
61+
62+
- Tests/inst_var_at_bad_idx.som
63+
- Tests/inst_var_at_put_bad_idx.som
64+
65+
- Tests/instance_fields_overlap/test.som
66+
- Tests/instance_fields_overlap2.som
67+
68+
- Tests/int5.som
69+
- Tests/int8.som
70+
- Tests/int9.som
71+
72+
- Tests/int10.som
73+
- Tests/int11.som
74+
- Tests/int12.som
75+
- Tests/int13.som
76+
- Tests/int14.som
77+
- Tests/int15.som
78+
- Tests/int16.som
79+
- Tests/int17.som
80+
81+
# too large shifts would take too much memory to support
82+
# need to specify this some how
83+
- Tests/int20.som
84+
- Tests/int21.som
85+
- Tests/int22.som
86+
- Tests/int23.som
87+
- Tests/int25.som
88+
- Tests/int27.som
89+
- Tests/int28.som
90+
- Tests/int31.som
91+
92+
# sqrt computes slightly different values
93+
- Tests/int26.som
94+
95+
# computes slightly different values
96+
- Tests/int_double_div.som
97+
98+
- Tests/int_double_div_err.som
99+
- Tests/int_double_div_zero_err.som
100+
# - Tests/int_modulus.som
101+
- Tests/int_modulus_err.som
102+
103+
- Tests/load_string.som
104+
105+
- Tests/mutate_methods.som
106+
- Tests/mutate_superclass_method/test.som
107+
108+
- Tests/nested_backtrace1.som
109+
- Tests/nested_backtrace2.som
110+
111+
- Tests/obj2.som
112+
113+
- Tests/perform_string.som
114+
- Tests/perform_witharguments_wrong.som
115+
116+
- Tests/remainder_zero.som
117+
118+
- Tests/shift_right.som
119+
- Tests/shift_right_too_big.som
120+
- Tests/shift_right_type_err.som
121+
122+
- Tests/str_escape_unknown.som
123+
124+
- Tests/system2.som
125+
126+
# computes slightly different values
127+
- Tests/sin.som
128+
- Tests/cos.som
129+
130+
# meaning of `-1.1 sqrt` not yet specified
131+
- Tests/double12.som
132+
133+
# specify nil, true, false as literals and not globals
134+
- Tests/system_global.som
135+
136+
- Tests/system_global_lookup_string.som
137+
- Tests/system_global_put_string.som
138+
139+
- Tests/test_literals_limit_1.som
140+
- Tests/test_literals_limit_2.som
141+
- Tests/unknown_field_write.som
142+
143+
# This should be specified so that the "set" of fields cannot be changed reflectively
144+
# they obtained array can be changed, but it is expected to have no effect.
145+
- Tests/mutate_fields.som
146+
147+
unsupported:
148+
# doesn't support utf-8/unicode yet
149+
# these work with normal Python as runner
150+
# - Tests/string_length.som
151+
# - Tests/is_letters.som
152+
153+
# TODO:
154+
- Tests/binary_super.som
155+
- Tests/perform_in_superclass_with_args.som
156+
- Tests/perform_unknown.som
157+
- Tests/perform_witharguments.som
158+
159+
# we expose that we're doing caching...
160+
- Tests/methods.som
161+
162+
163+
164+
do_not_run:
165+
- Tests/case_insensitive.som

src/rlib/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
"""Compatibility library for RPython
1+
"""
2+
Compatibility library for RPython
23
3-
This module contains ad hoc implementations and workarounds for Python
4-
library functions that is not directly supported by RPython.
4+
This module contains ad hoc implementations and workarounds for Python
5+
library functions that is not directly supported by RPython.
56
"""

src/rlib/float.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,25 @@
33
INFINITY = 1e200 * 1e200
44

55
try:
6-
from rpython.rlib.rfloat import formatd, DTSF_ADD_DOT_0, DTSF_STR_PRECISION
6+
from rpython.rlib.rfloat import formatd, DTSF_ADD_DOT_0
77
from rpython.rlib.rfloat import round_double # pylint: disable=unused-import
88

99
def float_to_str(value):
10-
return formatd(value, "g", DTSF_STR_PRECISION, DTSF_ADD_DOT_0)
10+
s = formatd(value, "f", 14, DTSF_ADD_DOT_0)
11+
s = s.rstrip("0")
12+
if s.endswith("."):
13+
s += "0"
14+
return s
1115

1216
except ImportError:
1317
"NOT_RPYTHON"
1418

1519
def float_to_str(value):
16-
return str(value)
20+
s = "%.14f" % value
21+
s = s.rstrip("0")
22+
if s.endswith("."):
23+
s += "0"
24+
return s
1725

1826
def round_double(value, _ndigits):
1927
# round() from libm, which is not available on all platforms!

src/rtruffle/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
"""A Basic Truffle-like Library
1+
"""
2+
A Basic Truffle-like Library
23
3-
This library is vaguely inspired by Truffle and provides some support
4-
classes to for AST-like interpreters.
4+
This library is vaguely inspired by Truffle and provides some support
5+
classes to for AST-like interpreters.
56
"""

src/som/primitives/integer_primitives.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,19 @@ def _greater_than_or_equal(left, right):
124124

125125

126126
def _left_shift(left, right):
127-
assert isinstance(right, Integer)
128-
129-
left_val = left.get_embedded_integer()
130-
right_val = right.get_embedded_integer()
131-
132-
assert isinstance(left_val, int)
133-
assert isinstance(right_val, int)
134-
135-
try:
136-
if not (left_val == 0 or 0 <= right_val < LONG_BIT):
137-
raise OverflowError
138-
result = ovfcheck(left_val << right_val)
139-
return Integer(result)
140-
except OverflowError:
141-
return BigInteger(bigint_from_int(left_val).lshift(right_val))
127+
if isinstance(left, Integer) and isinstance(right, Integer):
128+
left_val = left.get_embedded_integer()
129+
right_val = right.get_embedded_integer()
130+
131+
try:
132+
if not (left_val == 0 or 0 <= right_val < LONG_BIT):
133+
raise OverflowError
134+
result = ovfcheck(left_val << right_val)
135+
return Integer(result)
136+
except OverflowError:
137+
return BigInteger(bigint_from_int(left_val).lshift(right_val))
138+
else:
139+
assert False
142140

143141

144142
def _unsigned_right_shift(left, right):

src/som/primitives/object_primitives.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _inst_var_at(rcvr, idx):
3939

4040
def _inst_var_at_put(rcvr, idx, val):
4141
rcvr.set_field(idx.get_embedded_integer() - 1, val)
42-
return val
42+
return rcvr
4343

4444

4545
def _inst_var_named(rcvr, arg):

0 commit comments

Comments
 (0)