-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodulo.affine
More file actions
64 lines (56 loc) · 1.69 KB
/
Copy pathmodulo.affine
File metadata and controls
64 lines (56 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// SPDX-License-Identifier: PMPL-1.0-or-later
// SPDX-FileCopyrightText: 2025 hyperpolymath
//
// Auto-generated conformance tests for aLib spec: arithmetic/modulo
// Source: aggregate-library/specs/arithmetic/modulo.md
//
// Conforms to aLib arithmetic/modulo spec v1.0
/// Test: Basic modulo with positive integers
fn test_modulo_basic() -> TestResult {
let result = 7 % 3;
assert_eq(result, 1, "Basic modulo with positive integers");
Pass
}
/// Test: Modulo with no remainder
fn test_modulo_no_remainder() -> TestResult {
let result = 10 % 5;
assert_eq(result, 0, "Modulo with no remainder");
Pass
}
/// Test: Modulo returning non-zero remainder
fn test_modulo_nonzero() -> TestResult {
let result = 15 % 4;
assert_eq(result, 3, "Modulo returning non-zero remainder");
Pass
}
/// Test: Zero modulo non-zero
fn test_modulo_zero() -> TestResult {
let result = 0 % 5;
assert_eq(result, 0, "Zero modulo non-zero");
Pass
}
/// Test: Modulo with larger numbers
fn test_modulo_large() -> TestResult {
let result = 100 % 7;
assert_eq(result, 2, "Modulo with larger numbers");
Pass
}
/// Run all modulo conformance tests
fn test_alib_arithmetic_modulo() -> TestResult {
let suite = #{
name: "aLib arithmetic/modulo conformance",
tests: [
#{ name: "modulo_basic", test: test_modulo_basic },
#{ name: "modulo_no_remainder", test: test_modulo_no_remainder },
#{ name: "modulo_nonzero", test: test_modulo_nonzero },
#{ name: "modulo_zero", test: test_modulo_zero },
#{ name: "modulo_large", test: test_modulo_large }
]
};
let (passed, failed) = run_suite(suite);
if failed == 0 {
Pass
} else {
Fail("Some modulo conformance tests failed")
}
}