Skip to content

Commit

Permalink
Merge PR #54: Added test to check for nil semantics of uninitialized …
Browse files Browse the repository at this point in the history
…local variables and empty blocks
  • Loading branch information
smarr authored Aug 25, 2020
2 parents 924752e + c9ec8c1 commit 5eac328
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
15 changes: 15 additions & 0 deletions TestSuite/BasicInterpreterTests/Blocks.som
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,19 @@ Blocks = (
methodLocal := 3.
a + methodLocal] value: 5)
)

testEmptyZeroArg = (
[] value == nil ifTrue: [ ^ 1 ].
^ 2
)

testEmptyOneArg = (
([:x | ] value: 4) == nil ifTrue: [ ^ 1 ].
^ 2
)

testEmptyTwoArg = (
([:x :y | ] value: 4 with: 5) == nil ifTrue: [ ^ 1 ].
^ 2
)
)
2 changes: 1 addition & 1 deletion TestSuite/BasicInterpreterTests/NumberOfTests.som
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ NumberOfTests = (

"Return the known number of tests,
should be used in basic interpreter test harness to confirm completeness"
numberOfTests = ( ^ 52 )
numberOfTests = ( ^ 57 )
)
12 changes: 12 additions & 0 deletions TestSuite/BasicInterpreterTests/Regressions.som
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,16 @@ Regressions = (
'foo:' asSymbol == #foo: ifTrue: [ ^ 1 ].
^ 2
)

testUninitializedLocal = (
| local |
local == nil ifTrue: [ ^ 1 ].
^ 2
)

testUninitializedLocalInBlock = (
[ | local |
local == nil ifTrue: [ ^ 1 ] ] value.
^ 2
)
)

0 comments on commit 5eac328

Please sign in to comment.