Revision | f5e000057fb32faa2d828ab5757fd844b274fe53 (tree) |
---|---|
Time | 2024-04-12 06:26:52 |
Author | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
refactored
@@ -116,6 +116,11 @@ | ||
116 | 116 | local int count:=0; ///Semantics: instance var, with function-local scope |
117 | 117 | cons PRIMES:= [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]; |
118 | 118 | |
119 | + if count >= len(PRIMES) { | |
120 | + print("Warning: Can only check {len(PRIMES)} primes, {gotPrime) is not verified") | |
121 | + return | |
122 | + } | |
123 | + | |
119 | 124 | expect := PRIMES[count] |
120 | 125 | if expect != gotPrime { |
121 | 126 | printf("ERROR: Prime no {count} should be {expect}, but got {gotPrime}”) |
@@ -123,17 +128,15 @@ | ||
123 | 128 | count += 1; |
124 | 129 | }///ToContinue""" |
125 | 130 | if self.verifyCorrectPrime_count >= len(self.verifyCorrectPrime_PRIMES): |
126 | - print ("Warning: cannot verify prime (no %s): %s -- Only %s primes build-in" % ( | |
127 | - self.verifyCorrectPrime_count, gotPrime, len(self.verifyCorrectPrime_PRIMES))) | |
128 | - else: | |
129 | - expect = self.verifyCorrectPrime_PRIMES[self.verifyCorrectPrime_count] | |
130 | - if expect != gotPrime: | |
131 | - print ("ERROR: Prime no %s should be %s, but got %s" % (self.verifyCorrectPrime_count, expect, gotPrime)) | |
132 | - | |
131 | + print ("Warning: Can only check %s primes, {%s) is not verified" %( | |
132 | + len(self.verifyCorrectPrime_PRIMES), gotPrime)) | |
133 | + return | |
134 | + expect = self.verifyCorrectPrime_PRIMES[self.verifyCorrectPrime_count] | |
135 | + if expect != gotPrime: | |
136 | + print ("ERROR: Prime no %s should be %s, but got %s" % (self.verifyCorrectPrime_count, expect, gotPrime)) | |
133 | 137 | self.verifyCorrectPrime_count +=1 |
134 | 138 | |
135 | 139 | |
136 | - | |
137 | 140 | def powerOn__power(self, max): |
138 | 141 | """///CastleCode |
139 | 142 | powerOn() on self.power |