Added TSourceReader to allow reading source files. Initial work on T environment...
"{ Package: 'jv:tea/compiler' }"
"{ NameSpace: Smalltalk }"
TestCase subclass:#TParserTests
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Languages-Tea-Compiler-AST-Tests'
!
!TParserTests methodsFor:'tests'!
test_blockargs
| method |
method := TParser parseMethod: 'foo <^ Float> self select:[ :e <Float> | e = NaN ]'
"Created: / 21-08-2015 / 07:10:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 21-08-2015 / 23:04:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
test_locals
| method |
method := TParser parseMethod: 'foo <^ Float> | local1 <Integer> local2 <Float | Double> | ^ local1'.
method := TParser parseMethod: 'foo <^ Float> self something ifTrue:[ | local1 <Float | Double > | local + instvar ]'.
"Created: / 21-08-2015 / 07:06:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 21-08-2015 / 23:05:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
test_method_pattern_01
| method |
method := TParser parseMethod: 'foo < ^ Integer >'.
self assert: method returnTypeSpec notNil.
self assert: method returnTypeSpec type name = 'Integer'.
method := TParser parseMethod: 'foo: foo <Integer> < ^ Integer >'.
self assert: method returnTypeSpec notNil.
self assert: method returnTypeSpec type name = 'Integer'.
self assert: method arguments first typeSpec notNil.
self assert: method arguments first typeSpec type name = 'Integer'.
method := TParser parseMethod: '+ anObject <Integer> < ^ Integer >'.
self assert: method returnTypeSpec notNil.
self assert: method returnTypeSpec type name = 'Integer'.
self assert: method arguments first typeSpec notNil.
self assert: method arguments first typeSpec type name = 'Integer'.
self should: [ TParser parseMethod: '+ anObject ' ] raise: Error.
self should: [ TParser parseMethod: '+ anObject < >' ] raise: Error.
self should: [ TParser parseMethod: '+ anObject < i32 >' ] raise: Error.
self should: [ TParser parseMethod: '+ anObject < i32 > < i32 >' ] raise: Error.
self should: [ TParser parseMethod: '+ anObject < i32 > < ^ >' ] raise: Error.
self should: [ TParser parseMethod: '+ anObject < i32 > < ^ i32 ' ] raise: Error.
"Created: / 20-08-2015 / 17:01:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 21-08-2015 / 23:00:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !