예제 #1
0
 def testString(self):
     b = self.bufferFromString("-42 + 1 equals -41")
     self.assertEquals("-42", handleString(b))
     handleWhitespace(b)
     self.assertEquals("+", handleString(b))
     handleWhitespace(b)
     self.assertEquals("1", handleString(b))
     handleWhitespace(b)
     self.assertEquals("equals", handleString(b))
     handleWhitespace(b)
     self.assertEquals("-41", handleString(b))
예제 #2
0
 def testString(self):
     b = self.bufferFromString("-42 + 1 equals -41")
     self.assertEquals("-42", handleString(b))
     handleWhitespace(b)
     self.assertEquals("+", handleString(b))
     handleWhitespace(b)
     self.assertEquals("1", handleString(b))
     handleWhitespace(b)
     self.assertEquals("equals", handleString(b))
     handleWhitespace(b)
     self.assertEquals("-41", handleString(b))
예제 #3
0
    def testDecimalDigitScanning(self):
        b = self.bufferFromString("42 43!44")
        self.assertEquals(42, handleDecimalInt(b))
        self.assertEquals(" ", handleWhitespace(b))
        self.assertEquals(43, handleDecimalInt(b))

        b2 = self.bufferFromString("-1-2+3-4")
        self.assertEquals(-1, handleDecimalInt(b2))
        self.assertEquals(-2, handleDecimalInt(b2))
        self.assertEquals(3, handleDecimalInt(b2))
        self.assertEquals(-4, handleDecimalInt(b2))
        self.assertRaises(FormatError, handleDecimalInt, b2)
예제 #4
0
    def testDecimalDigitScanning(self):
        b = self.bufferFromString("42 43!44")
        self.assertEquals(42, handleDecimalInt(b))
        self.assertEquals(" ", handleWhitespace(b))
        self.assertEquals(43, handleDecimalInt(b))

        b2 = self.bufferFromString("-1-2+3-4")
        self.assertEquals(-1, handleDecimalInt(b2))
        self.assertEquals(-2, handleDecimalInt(b2))
        self.assertEquals(3, handleDecimalInt(b2))
        self.assertEquals(-4, handleDecimalInt(b2))
        self.assertRaises(FormatError, handleDecimalInt, b2)
예제 #5
0
 def testWhitespaceScanning(self):
     b = self.bufferFromString("    42\n43")
     self.assertEquals("    ", handleWhitespace(b))
     self.assertEquals("", handleWhitespace(b))
     self.assertEquals("4", b.getch())
예제 #6
0
 def testWhitespaceScanning(self):
     b = self.bufferFromString("    42\n43")
     self.assertEquals("    ", handleWhitespace(b))
     self.assertEquals("", handleWhitespace(b))
     self.assertEquals("4", b.getch())