Skip to content
This repository was archived by the owner on Jun 10, 2025. It is now read-only.

Commit eadbb0c

Browse files
committed
d
1 parent c59227d commit eadbb0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+373
-11
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,6 @@ htmlcov/**
112112

113113
# CProfile
114114
prof/**
115+
116+
# Wasm spec submodule
117+
./spec/**

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "spec"]
2+
path = spec
3+
url = git@github.com:WebAssembly/spec.git

spec

Submodule spec added at c4d85ce

tests/core/parsers/test_blocktype_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from wasm.exceptions import (
99
ParseError,
1010
)
11-
from wasm.parsers.blocks import (
11+
from wasm.parsers.binary.blocks import (
1212
parse_blocktype,
1313
)
1414

tests/core/parsers/test_floating_point_parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
)
99
import pytest
1010

11-
from wasm.parsers.floats import (
11+
from wasm.parsers.binary.floats import (
1212
parse_f32,
1313
parse_f64,
1414
)

tests/core/parsers/test_integer_parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from wasm.exceptions import (
66
MalformedModule,
77
)
8-
from wasm.parsers.integers import (
8+
from wasm.parsers.binary.integers import (
99
parse_i32,
1010
parse_i64,
1111
parse_s32,

tests/core/parsers/test_leb128_parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44

5-
from wasm.parsers.leb128 import (
5+
from wasm.parsers.binary.leb128 import (
66
parse_signed_leb128,
77
parse_unsigned_leb128,
88
)

tests/core/parsers/test_numeric_parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from wasm.opcodes import (
99
BinaryOpcode,
1010
)
11-
from wasm.parsers.numeric import (
11+
from wasm.parsers.binary.numeric import (
1212
parse_numeric_constant_instruction,
1313
)
1414

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import pytest
2+
3+
4+
from wasm.sexpressions import (
5+
sexp_parser,
6+
)
7+
8+
# Test vectors from: http://www.ccp4.ac.uk/dist/checkout/pyparsing-2.0.1/examples/sexpParser.py
9+
10+
test00 = """(snicker "abc" (#03# |YWJj|))"""
11+
test01 = """(certificate
12+
(issuer
13+
(name
14+
(public-key
15+
rsa-with-md5
16+
(e 15 |NFGq/E3wh9f4rJIQVXhS|)
17+
(n |d738/4ghP9rFZ0gAIYZ5q9y6iskDJwASi5rEQpEQq8ZyMZeIZzIAR2I5iGE=|))
18+
aid-committee))
19+
(subject
20+
(ref
21+
(public-key
22+
rsa-with-md5
23+
(e |NFGq/E3wh9f4rJIQVXhS|)
24+
(n |d738/4ghP9rFZ0gAIYZ5q9y6iskDJwASi5rEQpEQq8ZyMZeIZzIAR2I5iGE=|))
25+
tom
26+
mother))
27+
(not-before "1997-01-01_09:00:00")
28+
(not-after "1998-01-01_09:00:00")
29+
(tag
30+
(spend (account "12345678") (* numeric range "1" "1000"))))
31+
"""
32+
test02 = """(lambda (x) (* x x))"""
33+
test03 = """(def length
34+
(lambda (x)
35+
(cond
36+
((not x) 0)
37+
( t (+ 1 (length (cdr x))))
38+
)
39+
)
40+
)
41+
"""
42+
test04 = """(2:XX "abc" (#03# |YWJj|))"""
43+
test05 = """(if (is (window_name) "XMMS") (set_workspace 2))"""
44+
test06 = """(if
45+
(and
46+
(is (application_name) "Firefox")
47+
(or
48+
(contains (window_name) "Enter name of file to save to")
49+
(contains (window_name) "Save As")
50+
(contains (window_name) "Save Image")
51+
()
52+
)
53+
)
54+
(geometry "+140+122")
55+
)
56+
"""
57+
test07 = """(defun factorial (x)
58+
(if (zerop x) 1
59+
(* x (factorial (- x 1)))))
60+
"""
61+
test51 = """(2:XX "abc" (#30# |YWJj|))"""
62+
test51error = """(3:XX "abc" (#30# |YWJj|))"""
63+
64+
test52 = """
65+
(and
66+
(or (> uid 1000)
67+
(!= gid 20)
68+
)
69+
(> quota 5.0e+03)
70+
)
71+
"""
72+
73+
74+
@pytest.mark.parametrize(
75+
'value',
76+
(
77+
test00,
78+
),
79+
)
80+
def test_base_sexpression_parser(value):
81+
sexp = sexp_parser.parseString(value, parseAll=True)
82+
assert sexp

tests/spec/test_spec.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
)
44

55
import numpy
6+
import pytest
67

78
from wasm import (
89
Runtime,
@@ -43,3 +44,19 @@ def test_json_fixture(fixture_path, pytestconfig):
4344
instantiate_test_module(runtime.store),
4445
)
4546
run_fixture_test(fixture_path, runtime, stop_after_command_line)
47+
48+
49+
from wasm.sexpressions import sexp_parser
50+
51+
52+
@pytest.fixture
53+
def submodule_fixture_path():
54+
path = Path(__file__).parent.parent.parent / 'spec' / 'tests' / 'core' / 'custom.wast'
55+
return path
56+
57+
58+
def test_submodule_spec_fixture(submodule_fixture_path):
59+
with submodule_fixture_path.open('r') as fixture_file:
60+
fixture = sexp_parser.parseFile(fixture_file)
61+
62+
assert False

0 commit comments

Comments
 (0)