diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 335d6726..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 @@ -52,8 +53,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,11 +64,24 @@ 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 + - 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: 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 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, 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 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 7b596ac7..4fb7d752 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! 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/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): 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): 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)