Browse Source

big: Nicely align test suite results.

Jeroen van Rijn 4 years ago
parent
commit
1ad0743a52
2 changed files with 15 additions and 12 deletions
  1. 5 9
      core/math/big/private.odin
  2. 10 3
      core/math/big/test.py

+ 5 - 9
core/math/big/private.odin

@@ -1540,6 +1540,8 @@ _private_int_log :: proc(a: ^Int, base: DIGIT, allocator := context.allocator) -
 }
 
 
+
+
 /*
 	hac 14.61, pp608
 */
@@ -1708,9 +1710,7 @@ _private_inverse_modulo_odd :: proc(dest, a, b: ^Int, allocator := context.alloc
 	/*
 		2. [modified] `b` must be odd.
 	*/
-	if internal_is_even(b) {
-		return .Invalid_Argument;
-	}
+	if internal_is_even(b) { return .Invalid_Argument; }
 
 	/*
 		Init all our temps.
@@ -1730,9 +1730,7 @@ _private_inverse_modulo_odd :: proc(dest, a, b: ^Int, allocator := context.alloc
 	/*
 		If one of `x`, `y` is zero return an error!
 	*/
-	if internal_is_zero(x) || internal_is_zero(y) {
-		return .Invalid_Argument;
-	}
+	if internal_is_zero(x) || internal_is_zero(y) { return .Invalid_Argument; }
 
 	/*
 		3. `u` = `x`, `v` = `y`, `A` = 1, `B` = 0, `C` = 0, `D` = 1
@@ -1812,9 +1810,7 @@ _private_inverse_modulo_odd :: proc(dest, a, b: ^Int, allocator := context.alloc
 		/*
 			If not zero goto step 4.
 		*/
-		if internal_is_zero(u) {
-			break;
-		}
+		if internal_is_zero(u) { break; }
 	}
 
 	/*

+ 10 - 3
core/math/big/test.py

@@ -561,6 +561,13 @@ if __name__ == '__main__':
 	print("\n---- math/big tests ----")
 	print()
 
+	max_name = 0
+	for test_proc in TESTS:
+		max_name = max(max_name, len(test_proc.__name__))
+
+	fmt_string = "{name:>{max_name}}: {count_pass:7,} passes and {count_fail:7,} failures in {timing:9.3f} ms."
+	fmt_string = fmt_string.replace("{max_name}", str(max_name))
+
 	for test_proc in TESTS:
 		count_pass = 0
 		count_fail = 0
@@ -583,7 +590,7 @@ if __name__ == '__main__':
 				count_fail     += 1
 				total_failures += 1
 
-		print("{name}: {count_pass:,} passes and {count_fail:,} failures in {timing:.3f} ms.".format(name=test_proc.__name__, count_pass=count_pass, count_fail=count_fail, timing=TIMINGS[test_proc] * 1_000))
+		print(fmt_string.format(name=test_proc.__name__, count_pass=count_pass, count_fail=count_fail, timing=TIMINGS[test_proc] * 1_000))
 
 	for BITS, ITERATIONS in BITS_AND_ITERATIONS:
 		print()		
@@ -665,12 +672,12 @@ if __name__ == '__main__':
 				else:
 					count_fail     += 1; total_failures += 1
 
-			print("{name}: {count_pass:,} passes and {count_fail:,} failures in {timing:.3f} ms.".format(name=test_proc.__name__, count_pass=count_pass, count_fail=count_fail, timing=TIMINGS[test_proc] * 1_000))
+			print(fmt_string.format(name=test_proc.__name__, count_pass=count_pass, count_fail=count_fail, timing=TIMINGS[test_proc] * 1_000))
 
 	print()		
 	print("---- THE END ----")
 	print()
-	print("total: {count_pass:,} passes and {count_fail:,} failures in {timing:.3f} ms.".format(count_pass=total_passes, count_fail=total_failures, timing=TOTAL_TIME * 1_000))
+	print(fmt_string.format(name="total", count_pass=total_passes, count_fail=total_failures, timing=TOTAL_TIME * 1_000))
 
 	if total_failures:
 		exit(1)