Example #1
0
	def test_multiplication(self):
		self.assertTrue(state.is_done(ircbot.cmd_calc("1 * 1")))
		self.assertEqual(ircbot.cmd_calc("1 * 1").value, "1")
		self.assertTrue(state.is_done(ircbot.cmd_calc("-1 * 1")))
		self.assertEqual(ircbot.cmd_calc("-1 * 1").value, "-1")
		self.assertTrue(state.is_done(ircbot.cmd_calc("0.1 * 0.1")))
		self.assertEqual(ircbot.cmd_calc("0.1 * 0.1").value, "0.01")
Example #2
0
	def test_division(self):
		self.assertTrue(state.is_done(ircbot.cmd_calc("1 / 1")))
		self.assertEqual(ircbot.cmd_calc("1 / 1").value, "1")
		self.assertTrue(state.is_done(ircbot.cmd_calc("1 / 2")))
		self.assertEqual(ircbot.cmd_calc("1 / 2").value, "0")
		self.assertTrue(state.is_done(ircbot.cmd_calc("1.0 / 2")))
		self.assertEqual(ircbot.cmd_calc("1.0 / 2").value, "0.5")
Example #3
0
	def test_subtraction(self):
		self.assertTrue(state.is_done(ircbot.cmd_calc("1 - 1")))
		self.assertEqual(ircbot.cmd_calc("1 - 1").value, "0")
		self.assertTrue(state.is_done(ircbot.cmd_calc("-1 - 1")))
		self.assertEqual(ircbot.cmd_calc("-1 - 1").value, "-2")
		self.assertTrue(state.is_done(ircbot.cmd_calc("0.6 - 0.5")))
		self.assertEqual(ircbot.cmd_calc("0.6 - 0.5").value, "0.1")
Example #4
0
	def test_addition(self):
		self.assertTrue(state.is_done(ircbot.cmd_calc("1 + 1")))
		self.assertEqual(ircbot.cmd_calc("1 + 1").value, "2")
		self.assertTrue(state.is_done(ircbot.cmd_calc("-1 + 1")))
		self.assertEqual(ircbot.cmd_calc("-1 + 1").value, "0")
		self.assertTrue(state.is_done(ircbot.cmd_calc("0.5 + 0.5")))
		self.assertEqual(ircbot.cmd_calc("0.5 + 0.5").value, "1.0")
Example #5
0
	def test_none(self):
		self.assertTrue(state.is_next(ircbot.cmd_calc(None)))
Example #6
0
	def test_incorrect_parenthesis(self):
		self.assertTrue(state.is_next(ircbot.cmd_calc("2 * ((1 + 2)")))
		self.assertEqual(ircbot.cmd_calc("2 * ((1 + 2)").value, "2 * ((1 + 2)")
Example #7
0
	def test_correct_parenthesis(self):
		self.assertTrue(state.is_done(ircbot.cmd_calc("2 * (1 + 2)")))
		self.assertEqual(ircbot.cmd_calc("2 * (1 + 2)").value, "6")
Example #8
0
	def test_division_by_zero(self):
		self.assertTrue(state.is_next(ircbot.cmd_calc("1 / 0")))
		self.assertEqual(ircbot.cmd_calc("1 / 0").value, "1 / 0")
		self.assertTrue(state.is_next(ircbot.cmd_calc("1.0 / 0")))
		self.assertEqual(ircbot.cmd_calc("1.0 / 0").value, "1.0 / 0")
Example #9
0
	def test_single_negative_number_float(self):
		self.assertTrue(state.is_done(ircbot.cmd_calc("-1.0")))
		self.assertEqual(ircbot.cmd_calc("-1.0").value, "-1.0")
Example #10
0
	def test_single_positive_number(self):
		self.assertTrue(state.is_done(ircbot.cmd_calc("1")))
		self.assertEquals(ircbot.cmd_calc("1").value, "1")
Example #11
0
	def test_not_math(self):
		self.assertTrue(state.is_next(ircbot.cmd_calc("foo +1")))