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))
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)
def testWhitespaceScanning(self): b = self.bufferFromString(" 42\n43") self.assertEquals(" ", handleWhitespace(b)) self.assertEquals("", handleWhitespace(b)) self.assertEquals("4", b.getch())