示例#1
0
	def test_error(self):
		tok = 'NOSE'
		with self.assertRaises(TypeError) as err:
			res = swim_lexer.dump_tokens(tok)

		the_exception = err.exception
		self.assertEqual(err.exception[0], "Unknown text 'NOSE'" )
示例#2
0
	def test_number_token(self):
		for num in range(1,11):
			res = swim_lexer.dump_tokens(str(num))
			self.assertEqual(res, 'NUMBER')
示例#3
0
	def test_im_token(self):
		im = ('IM', 'im')
		for i in im:
			res = swim_lexer.dump_tokens(i)
			self.assertEqual(res, 'STROKE')
示例#4
0
	def test_fly_stroke_token(self):
		fly = ('Fl', 'fl', 'fly', 'Fly')
		for fl in fly:
			res = swim_lexer.dump_tokens(fl)
			self.assertEqual(res, 'STROKE')
示例#5
0
	def test_breast_stroke_token(self):
		breast = ('Br', 'br', 'Breast', 'breast')
		for br in breast:
			res = swim_lexer.dump_tokens(br)
			self.assertEqual(res, 'STROKE')
示例#6
0
	def test_back_stroke_token(self):
		back = ('Bk', 'bk', 'Back', 'back')
		for bk in back:
			res = swim_lexer.dump_tokens(bk)
			self.assertEqual(res, 'STROKE')
示例#7
0
	def test_free_stroke_token(self):
		free = ('Fr', 'fr', 'Free', 'free')
		for fr in free:
			res = swim_lexer.dump_tokens(fr)
			self.assertEqual(res, 'STROKE')
示例#8
0
	def test_zone_token(self):
		zone = ('EN1', 'Zone 2' , 'zone 3')
		for z in zone:
			res = swim_lexer.dump_tokens(z)
			self.assertEqual(res, 'ZONE')
示例#9
0
	def test_colon_token(self):
		c = ":"
		res = swim_lexer.dump_tokens(c)
		self.assertEqual(res, 'COLON')
示例#10
0
	def test_r_brace_token(self):
		r = "}"
		res = swim_lexer.dump_tokens(r)
		self.assertEqual(res, 'R_BRACKET')
示例#11
0
	def test_l_brace_token(self):
		l = "{"
		res = swim_lexer.dump_tokens(l)
		self.assertEqual(res, 'L_BRACKET')
示例#12
0
	def test_at_token(self):
		at = "@"
		res = swim_lexer.dump_tokens(at)
		self.assertEqual(res, 'AT')
示例#13
0
	def test_newline_no_token(self):
		newlines=('\n', '\r\n')
		for newline in newlines:
			res = swim_lexer.dump_tokens(newline)
			self.assertEqual(res, '')
示例#14
0
	def test_empty_string_no_tokens(self):
		s=''
		result = swim_lexer.dump_tokens(s)
		self.assertEqual(result, '')
示例#15
0
	def test_choice_token(self):
		choice = ('ch', 'Ch', 'choice', 'Choice')
		for ch in choice:
			res = swim_lexer.dump_tokens(ch)
			self.assertEqual(res, 'STROKE')
示例#16
0
	def test_mult_token(self):
		ms = ('x', 'X')
		for m in ms:
			res = swim_lexer.dump_tokens(m)
			self.assertEqual(res, 'MULT')
示例#17
0
	def test_kick_token(self):
		kick = ('K', 'k', 'Kick', 'kick')
		for k in kick:
			res = swim_lexer.dump_tokens(k)
			self.assertEqual(res, 'KICK')
示例#18
0
	def test_drill_token(self):
		drill = ('dr', 'Dr', 'drill', 'Drill')
		for dr in drill:
			res = swim_lexer.dump_tokens(dr)
			self.assertEqual(res, 'DRILL')