PPArithmeticParserTest.st
changeset 4 90de244a7fa2
parent 0 739fe9b7253e
child 48 5a795e7690d4
equal deleted inserted replaced
3:e1b11f74e142 4:90de244a7fa2
     1 "{ Package: 'squeak:petitparser' }"
     1 "{ Package: 'stx:goodies/petitparser' }"
     2 
     2 
     3 PPCompositeParserTest subclass:#PPArithmeticParserTest
     3 PPCompositeParserTest subclass:#PPArithmeticParserTest
     4 	instanceVariableNames:''
     4 	instanceVariableNames:''
     5 	classVariableNames:''
     5 	classVariableNames:''
     6 	poolDictionaries:''
     6 	poolDictionaries:''
    30 !PPArithmeticParserTest methodsFor:'testing-expression'!
    30 !PPArithmeticParserTest methodsFor:'testing-expression'!
    31 
    31 
    32 testBrackets
    32 testBrackets
    33 	self assert: '(1)' is: 1.
    33 	self assert: '(1)' is: 1.
    34 	self assert: '(1 + 2)' is: 3.
    34 	self assert: '(1 + 2)' is: 3.
    35 	
    35 
    36 	self assert: '((1))' is: 1.
    36 	self assert: '((1))' is: 1.
    37 	self assert: '((1 + 2))' is: 3.
    37 	self assert: '((1 + 2))' is: 3.
    38 
    38 
    39 	self assert: '2 * (3 + 4)' is: 14.
    39 	self assert: '2 * (3 + 4)' is: 14.
    40 	self assert: '(2 + 3) * 4' is: 20.
    40 	self assert: '(2 + 3) * 4' is: 20.
    76 testDivMany
    76 testDivMany
    77 	self assert: '100 / 2' is: 50.
    77 	self assert: '100 / 2' is: 50.
    78 	self assert: '100 / 2 / 2' is: 25.
    78 	self assert: '100 / 2 / 2' is: 25.
    79 	self assert: '100 / 2 / 2 / 5' is: 5.
    79 	self assert: '100 / 2 / 2 / 5' is: 5.
    80 	self assert: '100 / 2 / 2 / 5 / 5' is: 1
    80 	self assert: '100 / 2 / 2 / 5 / 5' is: 1
    81 	
    81 
    82 !
    82 !
    83 
    83 
    84 testMul
    84 testMul
    85 	self assert: '2 * 3' is: 6.
    85 	self assert: '2 * 3' is: 6.
    86 	self assert: '2 * -4' is: -8
    86 	self assert: '2 * -4' is: -8
   122 ! !
   122 ! !
   123 
   123 
   124 !PPArithmeticParserTest class methodsFor:'documentation'!
   124 !PPArithmeticParserTest class methodsFor:'documentation'!
   125 
   125 
   126 version_SVN
   126 version_SVN
   127     ^ '$Id: PPArithmeticParserTest.st,v 1.1 2011-08-18 18:56:17 cg Exp $'
   127     ^ '$Id: PPArithmeticParserTest.st,v 1.2 2012-01-13 11:22:50 cg Exp $'
   128 ! !
   128 ! !