compiler/tests/PPCompiledExpressionGrammarTest.st
changeset 438 20598d7ce9fa
child 452 9f4558b3be66
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compiler/tests/PPCompiledExpressionGrammarTest.st	Thu Apr 30 23:43:14 2015 +0200
@@ -0,0 +1,54 @@
+"{ Package: 'stx:goodies/petitparser/compiler/tests' }"
+
+"{ NameSpace: Smalltalk }"
+
+PPCompositeParserTest subclass:#PPCompiledExpressionGrammarTest
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitCompiler-Tests-ExpressionGrammar'
+!
+
+!PPCompiledExpressionGrammarTest class methodsFor:'as yet unclassified'!
+
+resources
+	^ (OrderedCollection with: PPCompiledExpressionGrammarResource)
+		addAll: super resources;
+		yourself
+! !
+
+!PPCompiledExpressionGrammarTest methodsFor:'as yet unclassified'!
+
+compilerArguments
+	^ PPCArguments default
+		profile: true;
+		ll: true;
+		yourself
+!
+
+context
+	^ PPCContext new
+!
+
+parserClass
+	^ Smalltalk at: #PPCompiledExpressionGrammar
+!
+
+parserInstanceFor: aSymbol
+	^ (Smalltalk at: #PPCompiledExpressionGrammar) new startSymbol: aSymbol
+!
+
+testNumber
+	result := self parse: '1' rule: #number.
+	self assert: result = 1.
+!
+
+testTerm
+	result := self parse: '1 + 2' rule: #term.
+	self assert: result size = 3.
+	self assert: result first = 1.
+	self assert: result second inputValue = '+'.
+	self assert: result third = 2.
+	
+! !
+