From 5be74eec87402d325f5fad991ddb977c970df913 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sun, 17 Aug 2025 23:47:00 +0100 Subject: [PATCH 1/8] Update core-lib and add integration-tests.yml Signed-off-by: Stefan Marr --- core-lib | 2 +- integration-tests.yml | 165 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 integration-tests.yml diff --git a/core-lib b/core-lib index 7bf0413d..a721b4ff 160000 --- a/core-lib +++ b/core-lib @@ -1 +1 @@ -Subproject commit 7bf0413d9e90e0484f5bde24f44b654c3672da24 +Subproject commit a721b4ff6ecb1ade54e0afe0bd15a8e80e41af17 diff --git a/integration-tests.yml b/integration-tests.yml new file mode 100644 index 00000000..c59fd40d --- /dev/null +++ b/integration-tests.yml @@ -0,0 +1,165 @@ +known_failures: [] + + +failing_as_unspecified: + - Tests/arbint_double_div_err.som + - Tests/arbint_double_div_zero_err.som + - Tests/arbint_modulus_err.som + - Tests/array_at_idx0_err.som + - Tests/array_at_idx2_err.som + - Tests/array_at_idx_err.som + - Tests/array_at_negative_idx_err.som + - Tests/array_at_put_idx0_err.som + - Tests/array_at_put_idx2_err.som + - Tests/call2.som + + # I think this one is about E vs e, but maybe also double rendering + - Tests/double2.som + # - Tests/double_double_div.som + # - Tests/int_double_div.som + - Tests/integer_asdouble.som + + # precision printing issues + - Tests/double1.som + + # I think IEEE allows for infinities here, and we probably want that + - Tests/double3.som + - Tests/double4.som + - Tests/double5.som + - Tests/double6.som + - Tests/double7.som + - Tests/double8.som + - Tests/double9.som + - Tests/double11.som + - Tests/double13.som + + # Java seems to do some rounding in the transition, but it's also requiring bigints + # - Tests/double_asinteger.som + + # computes slightly different values + - Tests/double_double_div.som + + - Tests/double_double_div_err.som + - Tests/double_double_div_zero_err1.som + - Tests/double_double_div_zero_err2.som + - Tests/double_double_div_zero_err3.som + - Tests/double_double_div_zero_err4.som + - Tests/double_modulus.som + - Tests/double_modulus_err.som + + - Tests/exit_double.som + - Tests/exit_int_too_big.som + - Tests/exit_string.som + + - Tests/fromstring_double_err.som + - Tests/fromstring_err.som + + # #methods returns an array, but it should be specified as not being + # the same array, so, it won't have the same hashcode: + - Tests/hashcode.som + - Tests/hashcode2.som + + - Tests/inst_var_at_bad_idx.som + - Tests/inst_var_at_put_bad_idx.som + + - Tests/instance_fields_overlap/test.som + - Tests/instance_fields_overlap2.som + + - Tests/int5.som + - Tests/int8.som + - Tests/int9.som + + - Tests/int10.som + - Tests/int11.som + - Tests/int12.som + - Tests/int13.som + - Tests/int14.som + - Tests/int15.som + - Tests/int16.som + - Tests/int17.som + + # too large shifts would take too much memory to support + # need to specify this some how + - Tests/int20.som + - Tests/int21.som + - Tests/int22.som + - Tests/int23.som + - Tests/int25.som + - Tests/int27.som + - Tests/int28.som + - Tests/int31.som + + # sqrt computes slightly different values + - Tests/int26.som + + # computes slightly different values + - Tests/int_double_div.som + + - Tests/int_double_div_err.som + - Tests/int_double_div_zero_err.som +# - Tests/int_modulus.som + - Tests/int_modulus_err.som + + - Tests/load_string.som + + - Tests/mutate_methods.som + - Tests/mutate_superclass_method/test.som + + - Tests/nested_backtrace1.som + - Tests/nested_backtrace2.som + + - Tests/obj2.som + + - Tests/perform_string.som + - Tests/perform_witharguments_wrong.som + + - Tests/remainder_zero.som + + - Tests/shift_right.som + - Tests/shift_right_too_big.som + - Tests/shift_right_type_err.som + + - Tests/str_escape_unknown.som + + - Tests/system2.som + + # computes slightly different values + - Tests/sin.som + - Tests/cos.som + + # meaning of `-1.1 sqrt` not yet specified + - Tests/double12.som + + # specify nil, true, false as literals and not globals + - Tests/system_global.som + + - Tests/system_global_lookup_string.som + - Tests/system_global_put_string.som + + - Tests/test_literals_limit_1.som + - Tests/test_literals_limit_2.som + - Tests/unknown_field_write.som + + # This should be specified so that the "set" of fields cannot be changed reflectively + # they obtained array can be changed, but it is expected to have no effect. + - Tests/mutate_fields.som + +unsupported: + # doesn't support utf-8/unicode yet + # these work with normal Python as runner + # - Tests/string_length.som + # - Tests/is_letters.som + + # TODO: + - Tests/binary_super.som + - Tests/perform_in_superclass_with_args.som + - Tests/perform_unknown.som + - Tests/perform_witharguments.som + + # we expose that we're doing caching... + - Tests/methods.som + + + +do_not_run: + - Tests/case_insensitive.som From 99d6e944264930174eba718351478078847f04d7 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sun, 17 Aug 2025 23:47:30 +0100 Subject: [PATCH 2/8] Adapt float printing to other SOM implementations Signed-off-by: Stefan Marr --- src/rlib/float.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/rlib/float.py b/src/rlib/float.py index 7b596ac7..232c6275 100644 --- a/src/rlib/float.py +++ b/src/rlib/float.py @@ -3,17 +3,25 @@ INFINITY = 1e200 * 1e200 try: - from rpython.rlib.rfloat import formatd, DTSF_ADD_DOT_0, DTSF_STR_PRECISION + from rpython.rlib.rfloat import formatd, DTSF_ADD_DOT_0 from rpython.rlib.rfloat import round_double # pylint: disable=unused-import def float_to_str(value): - return formatd(value, "g", DTSF_STR_PRECISION, DTSF_ADD_DOT_0) + s = formatd(value, "f", 14, DTSF_ADD_DOT_0) + s = s.rstrip('0') + if s.endswith('.'): + s += '0' + return s except ImportError: "NOT_RPYTHON" def float_to_str(value): - return str(value) + s = "%.14f" % value + s = s.rstrip('0') + if s.endswith('.'): + s += '0' + return s def round_double(value, _ndigits): # round() from libm, which is not available on all platforms! From c595d5ee8fc90351e40a3496006e6d6d5eaca3a1 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sun, 17 Aug 2025 23:48:02 +0100 Subject: [PATCH 3/8] Return receiver in #at:put: operations Signed-off-by: Stefan Marr --- src/som/primitives/object_primitives.py | 2 +- src/som/primitives/system_primitives.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/som/primitives/object_primitives.py b/src/som/primitives/object_primitives.py index f6ff186a..1b2e7899 100644 --- a/src/som/primitives/object_primitives.py +++ b/src/som/primitives/object_primitives.py @@ -39,7 +39,7 @@ def _inst_var_at(rcvr, idx): def _inst_var_at_put(rcvr, idx, val): rcvr.set_field(idx.get_embedded_integer() - 1, val) - return val + return rcvr def _inst_var_named(rcvr, arg): diff --git a/src/som/primitives/system_primitives.py b/src/som/primitives/system_primitives.py index be6cf133..ce87054b 100644 --- a/src/som/primitives/system_primitives.py +++ b/src/som/primitives/system_primitives.py @@ -30,9 +30,9 @@ def _has_global(_rcvr, arg): return falseObject -def _global_put(_rcvr, argument, value): +def _global_put(rcvr, argument, value): current_universe.set_global(argument, value) - return value + return rcvr def _print_string(rcvr, argument): From c9d4cde0b46ed9e14ab5c9b033c794c9880e68b5 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sun, 17 Aug 2025 23:49:28 +0100 Subject: [PATCH 4/8] Fix left shift a little Signed-off-by: Stefan Marr --- src/som/primitives/integer_primitives.py | 28 +++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/som/primitives/integer_primitives.py b/src/som/primitives/integer_primitives.py index aef00d97..195323aa 100644 --- a/src/som/primitives/integer_primitives.py +++ b/src/som/primitives/integer_primitives.py @@ -124,21 +124,19 @@ def _greater_than_or_equal(left, right): def _left_shift(left, right): - assert isinstance(right, Integer) - - left_val = left.get_embedded_integer() - right_val = right.get_embedded_integer() - - assert isinstance(left_val, int) - assert isinstance(right_val, int) - - try: - if not (left_val == 0 or 0 <= right_val < LONG_BIT): - raise OverflowError - result = ovfcheck(left_val << right_val) - return Integer(result) - except OverflowError: - return BigInteger(bigint_from_int(left_val).lshift(right_val)) + if isinstance(left, Integer) and isinstance(right, Integer): + left_val = left.get_embedded_integer() + right_val = right.get_embedded_integer() + + try: + if not (left_val == 0 or 0 <= right_val < LONG_BIT): + raise OverflowError + result = ovfcheck(left_val << right_val) + return Integer(result) + except OverflowError: + return BigInteger(bigint_from_int(left_val).lshift(right_val)) + else: + assert False def _unsigned_right_shift(left, right): From c4b223054aa480f56d07b22ee45e231a04b58c93 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sun, 17 Aug 2025 23:58:24 +0100 Subject: [PATCH 5/8] [CI] Make PyTest look in the tests folder only This avoids picking up the integration tests accidentally Signed-off-by: Stefan Marr --- .github/workflows/ci.yml | 6 +++--- .gitlab-ci.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 335d6726..b6893518 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,8 +52,8 @@ jobs: run: | export PYTHON=python export PYTHONPATH=src - SOM_INTERP=AST pytest - SOM_INTERP=BC pytest + SOM_INTERP=AST pytest tests + SOM_INTERP=BC pytest tests SOM_INTERP=AST ./som.sh -cp Smalltalk TestSuite/TestHarness.som SOM_INTERP=BC ./som.sh -cp Smalltalk TestSuite/TestHarness.som echo "[system exit: 0] value" | SOM_INTERP=AST ./som.sh -cp Smalltalk @@ -63,7 +63,7 @@ jobs: if: matrix.id != 'basic' run: | export SOM_INTERP=${{ matrix.interp }} - PYTHONPATH=$PYTHONPATH:.pypy:src pytest + PYTHONPATH=$PYTHONPATH:.pypy:src pytest tests PYTHONPATH=$PYTHONPATH:.pypy ./som.sh -cp Smalltalk TestSuite/TestHarness.som PYTHONPATH=$PYTHONPATH:.pypy .pypy/rpython/bin/rpython --batch src/main_rpython.py ./som-${{ matrix.id }}-interp -cp Smalltalk TestSuite/TestHarness.som diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1dcee6bf..3fbc00f4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,7 +56,7 @@ build-and-test-interpreters: - (cd Examples/Benchmarks/TestSuite && ./duplicate-tests.sh) # Unit Tests - - PYTHONPATH=src python3 -m pytest + - PYTHONPATH=src python3 -m pytest tests - ./som.sh -cp Smalltalk TestSuite/TestHarness.som # Interpreter @@ -67,7 +67,7 @@ build-and-test-interpreters: - export SOM_INTERP=AST # Unit Tests - - PYTHONPATH=src python3 -m pytest + - PYTHONPATH=src python3 -m pytest tests - ./som.sh -cp Smalltalk TestSuite/TestHarness.som # Interpreter From 08cb80c65fc3e1f2501ce0c38af89184942381cd Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Tue, 19 Aug 2025 11:10:43 +0100 Subject: [PATCH 6/8] [GHA] Added integration tests - add python-type to matrix to avoid issues with forgetting to update python versions in step guards Signed-off-by: Stefan Marr --- .github/workflows/ci.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6893518..54395753 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,7 @@ jobs: - name: Basics Python 3.13 python-version: 3.13 id: basic + python-type: cpython steps: - name: Checkout @@ -68,6 +69,19 @@ jobs: PYTHONPATH=$PYTHONPATH:.pypy .pypy/rpython/bin/rpython --batch src/main_rpython.py ./som-${{ matrix.id }}-interp -cp Smalltalk TestSuite/TestHarness.som + - name: Integration Tests + if: matrix.python-type == 'cpython' + run: | + pip install pyyaml + export VM=./som.sh + export CLASSPATH=Smalltalk + export TEST_EXPECTATIONS=./integration-tests.yml + export AWFY=Examples/AreWeFastYet/Core + + export PYTHON=python + SOM_INTERP=AST pytest core-lib/IntegrationTests + SOM_INTERP=BC pytest core-lib/IntegrationTests + - name: SomSom Tests if: matrix.id != 'basic' run: | @@ -78,13 +92,13 @@ jobs: run: | pip install black black --check --diff src tests - if: matrix.python-version == '3.11' + if: matrix.python-type == 'cpython' - name: Install and Run PyLint run: | pip install pylint pylint --init-hook="import sys; sys.setrecursionlimit(2000)" src tests - if: matrix.python-version == '3.11' + if: matrix.python-type == 'cpython' concurrency: From 53747b387e62d2006ea24285c361db36a883e710 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Tue, 19 Aug 2025 11:24:42 +0100 Subject: [PATCH 7/8] =?UTF-8?q?Applied=20black,=20GHA=20was=20not=20runnin?= =?UTF-8?q?g=20it=20for=20a=20while=20now=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Marr --- src/rlib/__init__.py | 7 ++++--- src/rlib/float.py | 12 ++++++------ src/rtruffle/__init__.py | 7 ++++--- trace-filter.py | 10 +++++----- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/rlib/__init__.py b/src/rlib/__init__.py index df1f3b2a..d3a1e6cf 100644 --- a/src/rlib/__init__.py +++ b/src/rlib/__init__.py @@ -1,5 +1,6 @@ -"""Compatibility library for RPython +""" +Compatibility library for RPython - This module contains ad hoc implementations and workarounds for Python - library functions that is not directly supported by RPython. +This module contains ad hoc implementations and workarounds for Python +library functions that is not directly supported by RPython. """ diff --git a/src/rlib/float.py b/src/rlib/float.py index 232c6275..4fb7d752 100644 --- a/src/rlib/float.py +++ b/src/rlib/float.py @@ -8,9 +8,9 @@ def float_to_str(value): s = formatd(value, "f", 14, DTSF_ADD_DOT_0) - s = s.rstrip('0') - if s.endswith('.'): - s += '0' + s = s.rstrip("0") + if s.endswith("."): + s += "0" return s except ImportError: @@ -18,9 +18,9 @@ def float_to_str(value): def float_to_str(value): s = "%.14f" % value - s = s.rstrip('0') - if s.endswith('.'): - s += '0' + s = s.rstrip("0") + if s.endswith("."): + s += "0" return s def round_double(value, _ndigits): diff --git a/src/rtruffle/__init__.py b/src/rtruffle/__init__.py index 9cd2b49b..43f8a2bf 100644 --- a/src/rtruffle/__init__.py +++ b/src/rtruffle/__init__.py @@ -1,5 +1,6 @@ -"""A Basic Truffle-like Library +""" +A Basic Truffle-like Library - This library is vaguely inspired by Truffle and provides some support - classes to for AST-like interpreters. +This library is vaguely inspired by Truffle and provides some support +classes to for AST-like interpreters. """ diff --git a/trace-filter.py b/trace-filter.py index d296c8ea..3810ec35 100644 --- a/trace-filter.py +++ b/trace-filter.py @@ -19,10 +19,10 @@ long_number = re.compile("\\d{8,}") for line in fileinput.input(): - filtered_line = re.sub(pointer, '(ptr)', line) - filtered_line = re.sub(target_token, 'TargetToken(tkn)', filtered_line) - filtered_line = re.sub(address, '[adr]', filtered_line) - filtered_line = re.sub(line_num, '', filtered_line) - filtered_line = re.sub(long_number, '(num)', filtered_line) + filtered_line = re.sub(pointer, "(ptr)", line) + filtered_line = re.sub(target_token, "TargetToken(tkn)", filtered_line) + filtered_line = re.sub(address, "[adr]", filtered_line) + filtered_line = re.sub(line_num, "", filtered_line) + filtered_line = re.sub(long_number, "(num)", filtered_line) sys.stdout.write(filtered_line) From 392087b46efe4e95c719d6f34c9e4d55e8d6008b Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Tue, 19 Aug 2025 11:28:15 +0100 Subject: [PATCH 8/8] PyLint: ignore too-many-positional-arguments Signed-off-by: Stefan Marr --- .pylintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.pylintrc b/.pylintrc index da8f5549..67ca1336 100644 --- a/.pylintrc +++ b/.pylintrc @@ -82,6 +82,7 @@ disable=raw-checker-failed, useless-object-inheritance, too-few-public-methods, too-many-arguments, + too-many-positional-arguments, too-many-function-args, too-many-locals, too-many-instance-attributes,