@@ -110,7 +110,7 @@ public handler TestDivide()
110110 test "divide (operator, int)" when 30 / tInt = 6
111111
112112 divide tInt by 2
113- test diagnostic "Expecting floor "
113+ test diagnostic "Expecting trunc "
114114 broken test "divide (syntax, int)" when tInt = 2 because "bug 14592"
115115
116116 variable tReal as Real
@@ -126,11 +126,46 @@ public handler TestDivide()
126126 test "divide (operator, number)" when tNumber / 8 = 2.5
127127end handler
128128
129- public handler TestMod()
130- test "mod (+ve, +ve)" when 10 mod 3 = 1
131- broken test "mod (-ve, +ve)" when -10 mod 3 = 2 because "bug 14593"
132- broken test "mod (+ve, -ve)" when 10 mod -3 = -2 because "bug 14593"
133- test "mod (-ve, -ve)" when -10 mod -3 = -1
129+ private handler ModInvariantDiagnostic(in pX, in pY, in pZ, in pR)
130+ test diagnostic pX formatted as string && "mod" && pY formatted as string
131+ test diagnostic pY formatted as string && "*" && \
132+ pZ formatted as string && "+" && \
133+ pR formatted as string && "=" && \
134+ (pY * pZ + pR) formatted as string
135+ end handler
136+
137+ private handler ModInvariantInteger(in pX as Integer, in pY as Integer) \
138+ returns Boolean
139+ variable tZ as Integer
140+ variable tR as Integer
141+ put (pX / pY) into tZ
142+ put (pX mod pY) into tR
143+
144+ ModInvariantDiagnostic(pX, pY, tZ, tR)
145+ return (pY * tZ + tR) is pX
146+ end handler
147+
148+ private handler ModInvariantReal(in pX as Real, in pY as Real) \
149+ returns Boolean
150+ variable tZ as Real
151+ variable tR as Real
152+ put the trunc of (pX / pY) into tZ -- because there is no "div" operator
153+ put (pX mod pY) into tR
154+
155+ ModInvariantDiagnostic(pX, pY, tZ, tR)
156+ return (pY * tZ + tR) is pX
157+ end handler
158+
159+ public handler TestModInteger()
160+ broken test "mod int (+ve, +ve)" when ModInvariantInteger(10, 3) because "bug 14592"
161+ broken test "mod (-ve, +ve)" when ModInvariantInteger(-10, 3) because "bug 14592"
162+ broken test "mod int (+ve, -ve)" when ModInvariantInteger(10, -3) because "bug 14592"
163+ broken test "mod int (-ve, -ve)" when ModInvariantInteger(-10, -3) because "bug 14592"
164+
165+ test "mod real (+ve, +ve)" when ModInvariantReal(16, 3.75)
166+ test "mod real (-ve, +ve)" when ModInvariantReal(-16, 3.75)
167+ test "mod real (+ve, -ve)" when ModInvariantReal(16, -3.75)
168+ test "mod real (-ve, -ve)" when ModInvariantReal(-16, -3.75)
134169end handler
135170
136171public handler TestWrap()
0 commit comments