Commit b8bc6f5b authored by Stefan Marr's avatar Stefan Marr

Added missing BasicInterpreterTests

Signed-off-by: 's avatarStefan Marr <git@stefan-marr.de>
parent 9fc5b63b
"
Copyright (c) 2001-2013 see AUTHORS file
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"
Blocks = (
----
arg1 = ( ^ [:a | a - 1] value: 43 )
arg2 = ( ^ [:a :b | a * b ] value: 11 with: 7 )
argAndLocal = (
^ ([:a |
| blockLocal |
blockLocal := 3.
a + blockLocal] value: 5)
)
argAndContext = ( | methodLocal |
^ ([:a |
methodLocal := 3.
a + methodLocal] value: 5)
)
)
"
Copyright (c) 2001-2013 see AUTHORS file
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"
MethodCall = (
----
test = (
^ self test2
)
test2 = ( ^ 42 )
)
"
Copyright (c) 2001-2013 see AUTHORS file
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"
NonLocalReturn = (
----
test = (
'test1 expect 42: ' println.
self test1 asString println.
'test2 expect 43: ' println.
self test2 asString println.
'test3 expect 3: ' println.
self test3 asString println.
)
test1 = ( | t1Frame |
[ | nlrFrame |
^ 42 ] value
)
test2 = ( ^ self test1 + 1 )
test3 = ( [ self test1. ^ 3 ] value )
test4 = ( ^ self at: 11 )
test5 = ( ^ self at: 10000 )
"Test case borrowed from Vector"
at: index = ( self checkIndex: index ifValid: [ ^ 42 ].
"else" ^ 22 )
checkIndex: index ifValid: block = (
(10 <= index) && (index <= 100)
ifTrue: [ ^ block value ]
ifFalse: [ #dontcare ]
)
)
"
Copyright (c) 2001-2013 see AUTHORS file
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"
Return = (
----
returnSelf = ( ^ self )
returnSelfImplicitly = ( )
noReturnReturnsSelf = ( 1 )
blockReturnsImplicitlyLastValue = ( ^ ([4] value) )
)
......@@ -29,7 +29,7 @@ class BasicInterpreterTest(unittest.TestCase):
("Return", "blockReturnsImplicitlyLastValue", 4, Integer )])
def test_basic_interpreter_behavior(self, test_class, test_selector, expected_result, result_type):
u = Universe()
u.setup_classpath("Smalltalk:BasicInterpreterTests")
u.setup_classpath("Smalltalk:TestSuite/BasicInterpreterTests")
actual_result = u.execute_method(test_class, test_selector)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment