Skip to content

Commit

Permalink
- let parseExpression raise errors early for now
Browse files Browse the repository at this point in the history
- remove testCompileInvalid as it is now valid to compile that code
  • Loading branch information
MarcusDenker committed Jun 29, 2020
1 parent da3e8eb commit 18e3253
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
3 changes: 2 additions & 1 deletion src/OpalCompiler-Core/OpalCompiler.class.st
Expand Up @@ -508,7 +508,8 @@ OpalCompiler >> parse: textOrString [

{ #category : #private }
OpalCompiler >> parseExpression [
^ (self compilationContext optionParseErrors or: [ self isInteractive not ])
"we should allow syntactically wrong code in evaluate, too"
^ (self compilationContext optionParseErrors "or: [ self isInteractive not ]")
ifTrue: [self parserClass parseFaultyExpression: source contents]
ifFalse: [self parserClass parseExpression: source contents]
]
Expand Down
22 changes: 0 additions & 22 deletions src/OpalCompiler-Tests/MethodPragmaTest.class.st
Expand Up @@ -171,28 +171,6 @@ MethodPragmaTest >> testCompileFull [
self assertPragma: 'foo: 1 bar: 2' givesKeyword: #foo:bar: arguments: #( 1 2 ).
]

{ #category : #'testing-compiler' }
MethodPragmaTest >> testCompileInvalid [
"Invalid pragmas should properly raise an error."

self should: [ self compile: '<>' selector: #zork ] raise: SyntaxErrorNotification.
self should: [ self compile: '<1>' selector: #zork ] raise: SyntaxErrorNotification.
self should: [ self compile: '<#123>' selector: #zork ] raise: SyntaxErrorNotification.

self should: [ self compile: '<foo bar>' selector: #zork ] raise: SyntaxErrorNotification.
self should: [ self compile: '<foo 1>' selector: #zork ] raise: SyntaxErrorNotification.
self should: [ self compile: '<foo bar zork>' selector: #zork ] raise: SyntaxErrorNotification.
self should: [ self compile: '<foo bar 1>' selector: #zork ] raise: SyntaxErrorNotification.

self should: [ self compile: '<foo: #bar: zork:>' selector: #zork ] raise: SyntaxErrorNotification.

self should: [ self compile: '<<1>' selector: #zork ] raise: SyntaxErrorNotification.
self should: [ self compile: '<=2>' selector: #zork ] raise: SyntaxErrorNotification.

self should: [ self compile: '< =1 = >' selector: #zork ] raise: SyntaxErrorNotification.
self should: [ self compile: '< =1 =2 >' selector: #zork ] raise: SyntaxErrorNotification.
]

{ #category : #'testing-compiler' }
MethodPragmaTest >> testCompileNumber [
self assertPragma: 'foo: 123' givesKeyword: #foo: arguments: #( 123 ).
Expand Down

0 comments on commit 18e3253

Please sign in to comment.