本文整理匯總了Python中ListOps.src.parser.Parser._read_list_of_numbers方法的典型用法代碼示例。如果您正苦於以下問題:Python Parser._read_list_of_numbers方法的具體用法?Python Parser._read_list_of_numbers怎麽用?Python Parser._read_list_of_numbers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ListOps.src.parser.Parser
的用法示例。
在下文中一共展示了Parser._read_list_of_numbers方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_read_list_of_one_number
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _read_list_of_numbers [as 別名]
def test_read_list_of_one_number(self):
value = "{12}"
scanner = Scanner(value)
parser = Parser(scanner)
parser._advance()
list = parser._read_list_of_numbers()
ref_list = List([Number(12)])
self.assertEqual(list, ref_list)
示例2: test_read_list_of_numbers
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _read_list_of_numbers [as 別名]
def test_read_list_of_numbers(self):
value = "{12,-3,12.42,-31.21,+41}"
scanner = Scanner(value)
parser = Parser(scanner)
parser._advance()
list = parser._read_list_of_numbers()
ref_list = List([Number(12), Number(-3), Number(12.42), Number(-31.21), Number(41)])
self.assertEqual(list, ref_list)
示例3: test_fail_to_read_list_of_numbers_with_wrong_element
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _read_list_of_numbers [as 別名]
def test_fail_to_read_list_of_numbers_with_wrong_element(self):
value = "{12,-3,a,-31.21,}"
scanner = Scanner(value)
parser = Parser(scanner)
parser._advance()
self.assertRaises(UnexpectedToken, lambda: parser._read_list_of_numbers())
示例4: test_fail_to_read_list_of_numbers_ending_with_comma
# 需要導入模塊: from ListOps.src.parser import Parser [as 別名]
# 或者: from ListOps.src.parser.Parser import _read_list_of_numbers [as 別名]
def test_fail_to_read_list_of_numbers_ending_with_comma(self):
value = "{12,-3,12.42,-31.21,}"
scanner = Scanner(value)
parser = Parser(scanner)
parser._advance()
self.assertRaises(UnexpectedToken, lambda: parser._read_list_of_numbers())