Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- name: Basics Python 3.13
python-version: 3.13
id: basic
python-type: cpython

steps:
- name: Checkout
Expand Down Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion core-lib
Submodule core-lib updated 252 files
165 changes: 165 additions & 0 deletions integration-tests.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions src/rlib/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
"""
14 changes: 11 additions & 3 deletions src/rlib/float.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
7 changes: 4 additions & 3 deletions src/rtruffle/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
"""
28 changes: 13 additions & 15 deletions src/som/primitives/integer_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/som/primitives/object_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/som/primitives/system_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 5 additions & 5 deletions trace-filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)