compiler/tests/PPCDistinctScannerTest.st
changeset 529 439c4057517f
parent 524 f6f68d32de73
child 534 a949c4fe44df
equal deleted inserted replaced
528:ebfddc82b8bb 529:439c4057517f
    57 
    57 
    58 testConsumeToken
    58 testConsumeToken
    59     | parser |
    59     | parser |
    60     parser := self fooToken, self overlappingToken.
    60     parser := self fooToken, self overlappingToken.
    61     parser compileWithConfiguration: configuration.
    61     parser compileWithConfiguration: configuration.
    62     scanner := (Smalltalk at: configuration arguments scannerName) new.
    62     scanner := (Smalltalk at: configuration options scannerName) new.
    63 
    63 
    64     scanner stream: 'foobaz' asPetitStream.
    64     scanner stream: 'foobaz' asPetitStream.
    65     scanner perform: #'consume_foo'.
    65     scanner perform: #'consume_foo'.
    66     
    66     
    67     self assert: scanner position = 3.
    67     self assert: scanner position = 3.
    71 
    71 
    72 testConsumeToken2
    72 testConsumeToken2
    73     | parser |
    73     | parser |
    74     parser := self fooToken, self barToken.
    74     parser := self fooToken, self barToken.
    75     parser compileWithConfiguration: configuration.
    75     parser compileWithConfiguration: configuration.
    76     scanner := (Smalltalk at: configuration arguments scannerName) new.
    76     scanner := (Smalltalk at: configuration options scannerName) new.
    77 
    77 
    78     scanner stream: 'foobar' asPetitStream.
    78     scanner stream: 'foobar' asPetitStream.
    79     scanner perform: #'consume_foo'.
    79     scanner perform: #'consume_foo'.
    80     
    80     
    81     self assert: scanner position = 3.
    81     self assert: scanner position = 3.
    86 testScan
    86 testScan
    87     | parser |
    87     | parser |
    88     parser := self aToken.
    88     parser := self aToken.
    89     parser compileWithConfiguration: configuration.
    89     parser compileWithConfiguration: configuration.
    90     
    90     
    91     scanner := (Smalltalk at: configuration arguments scannerName) new.
    91     scanner := (Smalltalk at: configuration options scannerName) new.
    92 
    92 
    93     scanner stream: 'a' asPetitStream.
    93     scanner stream: 'a' asPetitStream.
    94     scanner perform: #'scan_token'.
    94     scanner perform: #'scan_token'.
    95     
    95     
    96     self assert: scanner position = 0.
    96     self assert: scanner position = 0.
   101 testScan2
   101 testScan2
   102     | parser |
   102     | parser |
   103     parser := self fooToken.
   103     parser := self fooToken.
   104     parser compileWithConfiguration: configuration.
   104     parser compileWithConfiguration: configuration.
   105     
   105     
   106     scanner := (Smalltalk at: configuration arguments scannerName) new.
   106     scanner := (Smalltalk at: configuration options scannerName) new.
   107 
   107 
   108     scanner stream: 'foo' asPetitStream.
   108     scanner stream: 'foo' asPetitStream.
   109     scanner perform: #'scan_foo'.
   109     scanner perform: #'scan_foo'.
   110     
   110     
   111     self assert: scanner position = 0.
   111     self assert: scanner position = 0.
   116 testScan3
   116 testScan3
   117     | parser |
   117     | parser |
   118     parser := self fooToken.
   118     parser := self fooToken.
   119     parser compileWithConfiguration: configuration.
   119     parser compileWithConfiguration: configuration.
   120     
   120     
   121     scanner := (Smalltalk at: configuration arguments scannerName) new.
   121     scanner := (Smalltalk at: configuration options scannerName) new.
   122 
   122 
   123     scanner stream: 'bar' asPetitStream.
   123     scanner stream: 'bar' asPetitStream.
   124     scanner perform: #'scan_foo'.
   124     scanner perform: #'scan_foo'.
   125     
   125     
   126     self assert: scanner position = 0.
   126     self assert: scanner position = 0.
   131 testScan4
   131 testScan4
   132     | parser |
   132     | parser |
   133     parser := self fooToken, self idToken.
   133     parser := self fooToken, self idToken.
   134     parser compileWithConfiguration: configuration.
   134     parser compileWithConfiguration: configuration.
   135     
   135     
   136     scanner := (Smalltalk at: configuration arguments scannerName) new.
   136     scanner := (Smalltalk at: configuration options scannerName) new.
   137 
   137 
   138     scanner stream: 'foothere' asPetitStream.
   138     scanner stream: 'foothere' asPetitStream.
   139     scanner perform: #'scan_foo'.
   139     scanner perform: #'scan_foo'.
   140     
   140     
   141     self assert: scanner position = 0.
   141     self assert: scanner position = 0.
   152 testSequence
   152 testSequence
   153     | parser result |
   153     | parser result |
   154     parser := self fooTrimmingToken, self idTrimmingToken.
   154     parser := self fooTrimmingToken, self idTrimmingToken.
   155     parser compileWithConfiguration: configuration.
   155     parser compileWithConfiguration: configuration.
   156     
   156     
   157     scanner := (Smalltalk at: configuration arguments scannerName) new.
   157     scanner := (Smalltalk at: configuration options scannerName) new.
   158 
   158 
   159     scanner stream: 'foo there ' asPetitStream.
   159     scanner stream: 'foo there ' asPetitStream.
   160     scanner perform: #'foo'.
   160     scanner perform: #'foo'.
   161     
   161     
   162     self assert: scanner position = 0.
   162     self assert: scanner position = 0.
   180 testToken
   180 testToken
   181     | parser |
   181     | parser |
   182     parser := self fooToken, self idTrimmingToken.
   182     parser := self fooToken, self idTrimmingToken.
   183     parser compileWithConfiguration: configuration.
   183     parser compileWithConfiguration: configuration.
   184     
   184     
   185     scanner := (Smalltalk at: configuration arguments scannerName) new.
   185     scanner := (Smalltalk at: configuration options scannerName) new.
   186 
   186 
   187     scanner stream: 'foo there' asPetitStream.
   187     scanner stream: 'foo there' asPetitStream.
   188     scanner perform: #'foo'.
   188     scanner perform: #'foo'.
   189     
   189     
   190     self assert: scanner position = 0.
   190     self assert: scanner position = 0.
   196 testTrimmingScan
   196 testTrimmingScan
   197     | parser |
   197     | parser |
   198     parser := self fooTrimmingToken, self idTrimmingToken.
   198     parser := self fooTrimmingToken, self idTrimmingToken.
   199     parser compileWithConfiguration: configuration.
   199     parser compileWithConfiguration: configuration.
   200     
   200     
   201     scanner := (Smalltalk at: configuration arguments scannerName) new.
   201     scanner := (Smalltalk at: configuration options scannerName) new.
   202 
   202 
   203     scanner stream: 'foo there' asPetitStream.
   203     scanner stream: 'foo there' asPetitStream.
   204     scanner perform: #'scan_foo'.
   204     scanner perform: #'scan_foo'.
   205     
   205     
   206     self assert: scanner position = 0.
   206     self assert: scanner position = 0.
   211 testTrimmingToken
   211 testTrimmingToken
   212     | parser result |
   212     | parser result |
   213     parser := self fooTrimmingToken, self idTrimmingToken.
   213     parser := self fooTrimmingToken, self idTrimmingToken.
   214     parser compileWithConfiguration: configuration.
   214     parser compileWithConfiguration: configuration.
   215     
   215     
   216     scanner := (Smalltalk at: configuration arguments scannerName) new.
   216     scanner := (Smalltalk at: configuration options scannerName) new.
   217 
   217 
   218     scanner stream: 'foo there' asPetitStream.
   218     scanner stream: 'foo there' asPetitStream.
   219     result := scanner perform: #'foo'.
   219     result := scanner perform: #'foo'.
   220     
   220     
   221     self assert: scanner position = 0.
   221     self assert: scanner position = 0.