Skip to content

Commit 8183ef6

Browse files
committed
Update Repetition and number element test cases
Re changes to Repetition and Integer *max* constructor arguments.
1 parent ce130ca commit 8183ef6

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

documentation/test_grammar_elements_basic_doctest.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Basic usage::
178178
Exact number of repetitions::
179179

180180
>>> seq = Sequence([Literal("hello"), Literal("world")])
181-
>>> rep = Repetition(seq, min=3, max=None, optimize=False)
181+
>>> rep = Repetition(seq, min=3, max=3, optimize=False)
182182
>>> test_rep = ElementTester(rep)
183183
>>> test_rep.recognize("hello world")
184184
RecognitionFailure
@@ -189,12 +189,12 @@ Exact number of repetitions::
189189
>>> test_rep.recognize("hello world hello world hello world hello world")
190190
RecognitionFailure
191191

192-
min must be less than max::
192+
min must be less than or equal to max::
193193

194-
>>> rep = Repetition(Literal("hello"), min=3, max=3, optimize=False)
194+
>>> rep = Repetition(Literal("hello"), min=4, max=3, optimize=False)
195195
Traceback (most recent call last):
196196
...
197-
AssertionError: min must be less than max
197+
AssertionError: min must be less than or equal to max
198198

199199

200200
Modifier element class

documentation/test_recobs_doctest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Simple literal element recognitions::
8888

8989
Integer element recognitions::
9090

91-
>>> test_int = ElementTester(Integer(min=1, max=100))
91+
>>> test_int = ElementTester(Integer(min=1, max=99))
9292
>>> test_int.recognize("seven")
9393
7
9494
>>> test_recobs.waiting, test_recobs.words

dragonfly/test/test_language_en_number.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ def _build_element(self):
6767
]
6868

6969

70-
class Limit3to14TestCase(ElementTestCase):
71-
""" Verify integer limits of range 3 -- 14. """
70+
class Limit3to13TestCase(ElementTestCase):
71+
""" Verify integer limits of range 3 -- 13. """
7272
def _build_element(self):
73-
return Integer(content=IntegerContent, min=3, max=14)
73+
return Integer(content=IntegerContent, min=3, max=13)
7474
input_output = [
7575
("oh", RecognitionFailure),
7676
("zero", RecognitionFailure),
@@ -96,10 +96,10 @@ def _build_element(self):
9696
]
9797

9898

99-
class Limit23to47TestCase(ElementTestCase):
100-
""" Verify integer limits of range 23 -- 47. """
99+
class Limit23to46TestCase(ElementTestCase):
100+
""" Verify integer limits of range 23 -- 46. """
101101
def _build_element(self):
102-
return Integer(content=IntegerContent, min=23, max=47)
102+
return Integer(content=IntegerContent, min=23, max=46)
103103
input_output = [
104104
("twenty two", RecognitionFailure),
105105
("twenty three", 23),
@@ -108,10 +108,10 @@ def _build_element(self):
108108
]
109109

110110

111-
class Limit230to350TestCase(ElementTestCase):
112-
""" Verify integer limits of range 230 -- 350. """
111+
class Limit230to349TestCase(ElementTestCase):
112+
""" Verify integer limits of range 230 -- 349. """
113113
def _build_element(self):
114-
return Integer(content=IntegerContent, min=230, max=350)
114+
return Integer(content=IntegerContent, min=230, max=349)
115115
input_output = [
116116
("two hundred twenty nine", RecognitionFailure),
117117
("two hundred thirty", 230),
@@ -125,10 +125,10 @@ def _build_element(self):
125125
]
126126

127127

128-
class Limit351TestCase(ElementTestCase):
129-
""" Verify integer limits of range up to 351. """
128+
class Limit350TestCase(ElementTestCase):
129+
""" Verify integer limits of range up to 350. """
130130
def _build_element(self):
131-
return Integer(content=IntegerContent, min=230, max=351)
131+
return Integer(content=IntegerContent, min=230, max=350)
132132
input_output = [
133133
("three hundred forty nine", 349),
134134
("three hundred fifty", 350),
@@ -137,10 +137,10 @@ def _build_element(self):
137137
]
138138

139139

140-
class Limit352TestCase(ElementTestCase):
141-
""" Verify integer limits of range up to 352. """
140+
class Limit351TestCase(ElementTestCase):
141+
""" Verify integer limits of range up to 351. """
142142
def _build_element(self):
143-
return Integer(content=IntegerContent, min=230, max=352)
143+
return Integer(content=IntegerContent, min=230, max=351)
144144
input_output = [
145145
("three hundred forty nine", 349),
146146
("three hundred fifty", 350),
@@ -153,7 +153,7 @@ def _build_element(self):
153153
class DigitsTestCase(ElementTestCase):
154154
""" Verify that digits between 0 and 10 can be recognized. """
155155
def _build_element(self):
156-
return Digits(content=DigitsContent, min=1, max=6)
156+
return Digits(content=DigitsContent, min=1, max=5)
157157
input_output = [
158158
("zero", [0]),
159159
("oh", [0]),
@@ -182,7 +182,7 @@ def _build_element(self):
182182
class DigitsAsIntTestCase(ElementTestCase):
183183
""" Verify that Digits used with as_int=True gives correct values. """
184184
def _build_element(self):
185-
return Digits(content=DigitsContent, min=1, max=6, as_int=True)
185+
return Digits(content=DigitsContent, min=1, max=5, as_int=True)
186186
input_output = [
187187
("zero", 0),
188188
("oh", 0),

0 commit comments

Comments
 (0)