Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
grumpy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
grumpy
Commits
4c564b02
Commit
4c564b02
authored
Jan 18, 2017
by
Dylan Trotter
Committed by
GitHub
Jan 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make acceptance tests pass under CPython. (#151)
parent
35d1202f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
44 additions
and
38 deletions
+44
-38
Makefile
Makefile
+10
-1
runtime/core.go
runtime/core.go
+1
-1
runtime/core_test.go
runtime/core_test.go
+1
-1
testing/assign_test.py
testing/assign_test.py
+1
-1
testing/builtin_test.py
testing/builtin_test.py
+3
-2
testing/function_test.py
testing/function_test.py
+7
-6
testing/import_test.py
testing/import_test.py
+1
-1
testing/md5_test.py
testing/md5_test.py
+0
-5
testing/op_test.py
testing/op_test.py
+5
-4
testing/str_test.py
testing/str_test.py
+15
-16
No files found.
Makefile
View file @
4c564b02
...
...
@@ -64,6 +64,7 @@ STDLIB_PASS_FILES := $(patsubst %,$(PKG_DIR)/grumpy/lib/%.pass,$(STDLIB_TESTS))
ACCEPT_TESTS
:=
$(
patsubst
%.py,%,
$(
wildcard
testing/
*
.py
))
ACCEPT_PASS_FILES
:=
$(
patsubst
%,build/%.pass,
$(ACCEPT_TESTS)
)
ACCEPT_PY_PASS_FILES
:=
$(
patsubst
%,build/%_py.pass,
$(
filter-out
%/native_test,
$(ACCEPT_TESTS)
))
BENCHMARKS
:=
$(
patsubst
%.py,%,
$(
wildcard
benchmarks/
*
.py
))
BENCHMARK_BINS
:=
$(
patsubst
%,build/%_benchmark,
$(BENCHMARKS)
)
...
...
@@ -84,7 +85,7 @@ clean:
run
:
$(RUNNER)
@
$(RUNNER_BIN)
test
:
$(ACCEPT_PASS_FILES) $(COMPILER_PASS_FILES) $(COMPILER_EXPR_VISITOR_PASS_FILES) $(COMPILER_STMT_PASS_FILES) $(RUNTIME_PASS_FILE) $(STDLIB_PASS_FILES)
test
:
$(ACCEPT_PASS_FILES) $(
ACCEPT_PY_PASS_FILES) $(
COMPILER_PASS_FILES) $(COMPILER_EXPR_VISITOR_PASS_FILES) $(COMPILER_STMT_PASS_FILES) $(RUNTIME_PASS_FILE) $(STDLIB_PASS_FILES)
precommit
:
cover gofmt lint test
...
...
@@ -206,6 +207,9 @@ $(eval $(foreach x,$(shell seq $(words $(STDLIB_SRCS))),$(call GRUMPY_STDLIB,$(w
# Acceptance tests & benchmarks
# ------------------------------------------------------------------------------
$(PY_DIR)/weetest.py
:
lib/weetest.py
@
cp
-f
$<
$@
$(patsubst %_test,build/%.go,$(ACCEPT_TESTS))
:
build/%.go: %_test.py $(COMPILER)
@
mkdir
-p
$
(
@D
)
@
$(COMPILER_BIN)
$<
>
$@
...
...
@@ -220,6 +224,11 @@ $(ACCEPT_PASS_FILES): build/%_test.pass: build/%_test
@
touch
$@
@
echo
'$*_test PASS'
$(ACCEPT_PY_PASS_FILES)
:
build/%_py.pass: %.py $(PY_DIR)/weetest.py
@
$(PYTHON)
$<
@
touch
$@
@
echo
'$*_py PASS'
$(patsubst %,build/%.go,$(BENCHMARKS))
:
build/%.go: %.py $(COMPILER)
@
mkdir
-p
$
(
@D
)
@
$(COMPILER_BIN)
$<
>
$@
...
...
runtime/core.go
View file @
4c564b02
...
...
@@ -755,7 +755,7 @@ func Tie(f *Frame, t TieTarget, o *Object) *BaseException {
return
raised
}
}
else
if
raised
.
isInstance
(
StopIterationType
)
{
return
f
.
RaiseType
(
Typ
eErrorType
,
fmt
.
Sprintf
(
"need more than %d values to unpack"
,
i
))
return
f
.
RaiseType
(
Valu
eErrorType
,
fmt
.
Sprintf
(
"need more than %d values to unpack"
,
i
))
}
else
{
return
raised
}
...
...
runtime/core_test.go
View file @
4c564b02
...
...
@@ -999,7 +999,7 @@ func TestTie(t *testing.T) {
},
NewList
(
NewStr
(
"foo"
)
.
ToObject
())
.
ToObject
(),
nil
,
mustCreateException
(
Typ
eErrorType
,
"need more than 1 values to unpack"
),
mustCreateException
(
Valu
eErrorType
,
"need more than 1 values to unpack"
),
},
{
TieTarget
{
Children
:
[]
TieTarget
{{
Target
:
&
targets
[
0
]}}},
...
...
testing/assign_test.py
View file @
4c564b02
...
...
@@ -44,7 +44,7 @@ else:
try
:
bar
,
baz
,
qux
,
quux
=
foo
except
Typ
eError
as
e
:
except
Valu
eError
as
e
:
assert
str
(
e
)
==
'need more than 3 values to unpack'
else
:
raise
AssertionError
(
'this was supposed to raise an exception'
)
...
...
testing/builtin_test.py
View file @
4c564b02
...
...
@@ -279,8 +279,9 @@ assert zip([1, 2, 3], [1, 2], [4], []) == []
assert
zip
([],
[
1
],
[
1
,
2
],
[
1
,
2
,
3
])
==
[]
try
:
zip
([
1
,
2
,
3
],
[
1
,
2
],
[
4
],
None
)
except
TypeError
as
e
:
assert
str
(
e
)
==
"'NoneType' object is not iterable"
raise
AssertionError
except
TypeError
:
pass
# Test map
...
...
testing/function_test.py
View file @
4c564b02
...
...
@@ -31,13 +31,13 @@ except TypeError as e:
try
:
foo
()
raise
AssertionError
except
TypeError
as
e
:
assert
str
(
e
)
==
'foo() takes at least 1 arguments (0 given)'
except
TypeError
:
pass
try
:
foo
(
1
,
2
,
3
)
# pylint: disable=too-many-function-args
raise
AssertionError
except
TypeError
as
e
:
assert
str
(
e
)
==
'foo() takes 1 arguments (3 given)'
except
TypeError
:
pass
def
foo
(
a
,
b
):
...
...
@@ -54,8 +54,9 @@ except TypeError as e:
assert
str
(
e
)
==
"foo() got multiple values for keyword argument 'a'"
try
:
foo
(
**
{
123
:
'bar'
})
except
TypeError
as
e
:
assert
str
(
e
)
==
'keywords must be strings'
,
str
(
e
)
pass
except
TypeError
:
pass
def
foo
(
a
,
b
=
None
):
...
...
testing/import_test.py
View file @
4c564b02
...
...
@@ -14,4 +14,4 @@
import
sys
print
sys
.
goversion
print
sys
.
maxint
testing/md5_test.py
View file @
4c564b02
...
...
@@ -13,11 +13,6 @@
# limitations under the License.
import
md5
import
_md5
# md5 test
assert
_md5
.
new
(
""
).
hexdigest
()
==
'd41d8cd98f00b204e9800998ecf8427e'
assert
_md5
.
new
(
"hello"
).
hexdigest
()
==
'5d41402abc4b2a76b9719d911017c592'
assert
md5
.
new
(
""
).
hexdigest
()
==
'd41d8cd98f00b204e9800998ecf8427e'
assert
md5
.
new
(
"hello"
).
hexdigest
()
==
'5d41402abc4b2a76b9719d911017c592'
testing/op_test.py
View file @
4c564b02
...
...
@@ -14,7 +14,8 @@
"""Arithmetic and boolean operator tests."""
from
__go__.math
import
IsNaN
,
IsInf
import
math
import
weetest
...
...
@@ -68,13 +69,13 @@ def TestNeg():
assert
-
x
==
-
0.0
x
=
float
(
'inf'
)
assert
IsInf
(
-
x
,
-
1
)
assert
math
.
isinf
(
-
x
)
x
=
-
float
(
'inf'
)
assert
IsInf
(
-
x
,
1
)
assert
math
.
isinf
(
-
x
)
x
=
float
(
'nan'
)
assert
IsNaN
(
-
x
)
assert
math
.
isnan
(
-
x
)
x
=
long
(
100
)
assert
-
x
==
-
100
...
...
testing/str_test.py
View file @
4c564b02
...
...
@@ -61,11 +61,8 @@ class Foo(object):
return
3
assert
'abcd'
.
find
(
'a'
,
Foo
())
==
-
1
try
:
'ab'
.
find
(
'xxx'
,
sys
.
maxsize
+
1
,
0
)
raise
AssertionError
except
IndexError
:
pass
# TODO: This raises IndexError under Grumpy but returns -1 for CPython.
# 'ab'.find('xxx', sys.maxsize + 1, 0)
try
:
"foo"
.
find
(
123
)
...
...
@@ -85,17 +82,19 @@ try:
except
TypeError
:
pass
try
:
'foobar'
.
find
(
"bar"
,
"baz"
)
raise
AssertionError
except
IndexError
:
pass
try
:
'foobar'
.
find
(
"bar"
,
0
,
"baz"
)
raise
AssertionError
except
IndexError
:
pass
# TODO: Both of these test cases raise TypeError under CPython but raise
# IndexError under Grumpy.
#try:
# 'foobar'.find("bar", "baz")
# raise AssertionError
#except TypeError:
# pass
#try:
# 'foobar'.find("bar", 0, "baz")
# raise AssertionError
#except TypeError:
# pass
# Test Mod
assert
"%s"
%
42
==
"42"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment