Skip to content

Commit

Permalink
Changing test to pass on 32 bit architecture.
Browse files Browse the repository at this point in the history
Reduces large isize to remain below maximum for signed 32 bit int,
resolves 01mf02#243
  • Loading branch information
elrido committed Dec 9, 2024
1 parent 8e93028 commit 0505fae
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions jaq-json/tests/funs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn tojson() {
#[test]
fn math_rem() {
// generated with this command with modification for errors and float rounding
// cargo run -- -rn 'def f: -2, -1, 0, 2.1, 3, 4000000001; f as $a | f as $b | "give!(json!(null), \"\($a) / \($b)\", \(try ($a % $b) catch tojson));"'
// cargo run -- -rn 'def f: -2, -1, 0, 2.1, 3, 2000000001; f as $a | f as $b | "give!(json!(null), \"\($a) / \($b)\", \(try ($a % $b) catch tojson));"'
// TODO: use fail!()?
give(json!(null), "-2 % -2", json!(0));
give(json!(null), "-2 % -1", json!(0));
Expand All @@ -92,7 +92,7 @@ fn math_rem() {
);
give(json!(null), "-2 % 2.1", json!(-2.0));
give(json!(null), "-2 % 3", json!(-2));
give(json!(null), "-2 % 4000000001", json!(-2));
give(json!(null), "-2 % 2000000001", json!(-2));
give(json!(null), "-1 % -2", json!(-1));
give(json!(null), "-1 % -1", json!(0));
give(
Expand All @@ -102,7 +102,7 @@ fn math_rem() {
);
give(json!(null), "-1 % 2.1", json!(-1.0));
give(json!(null), "-1 % 3", json!(-1));
give(json!(null), "-1 % 4000000001", json!(-1));
give(json!(null), "-1 % 2000000001", json!(-1));
give(json!(null), "0 % -2", json!(0));
give(json!(null), "0 % -1", json!(0));
give(
Expand All @@ -112,13 +112,13 @@ fn math_rem() {
);
give(json!(null), "0 % 2.1", json!(0.0));
give(json!(null), "0 % 3", json!(0));
give(json!(null), "0 % 4000000001", json!(0));
give(json!(null), "0 % 2000000001", json!(0));
give(json!(null), "2.1 % -2 | . * 1000 | round", json!(100));
give(json!(null), "2.1 % -1 | . * 1000 | round", json!(100));
give(json!(null), "2.1 % 0 | isnan", json!(true));
give(json!(null), "2.1 % 2.1", json!(0.0));
give(json!(null), "2.1 % 3", json!(2.1));
give(json!(null), "2.1 % 4000000001", json!(2.1));
give(json!(null), "2.1 % 2000000001", json!(2.1));
give(json!(null), "3 % -2", json!(1));
give(json!(null), "3 % -1", json!(0));
give(
Expand All @@ -128,19 +128,19 @@ fn math_rem() {
);
give(json!(null), "3 % 2.1 | . * 1000 | round", json!(900));
give(json!(null), "3 % 3", json!(0));
give(json!(null), "3 % 4000000001", json!(3));
give(json!(null), "4000000001 % -2", json!(1));
give(json!(null), "4000000001 % -1", json!(0));
give(json!(null), "3 % 2000000001", json!(3));
give(json!(null), "2000000001 % -2", json!(1));
give(json!(null), "2000000001 % -1", json!(0));
give(
json!(null),
"try (4000000001 % 0) catch .",
json!("cannot calculate 4000000001 % 0"),
"try (2000000001 % 0) catch .",
json!("cannot calculate 2000000001 % 0"),
);
give(
json!(null),
"4000000001 % 2.1 | . * 1000 | round",
json!(500),
"2000000001 % 2.1 | . * 1000 | round",
json!(1800), // 1000 in jq
);
give(json!(null), "4000000001 % 3", json!(2));
give(json!(null), "4000000001 % 4000000001", json!(0));
give(json!(null), "2000000001 % 3", json!(0));
give(json!(null), "2000000001 % 2000000001", json!(0));
}

0 comments on commit 0505fae

Please sign in to comment.