Skip to content

Commit

Permalink
Lower fuel consumption threshold from 10% to 2% (#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcharles authored Nov 25, 2024
1 parent 72985bc commit 96a7951
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions crates/cli/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn test_fib(builder: &mut Builder) -> Result<()> {

let (output, _, fuel_consumed) = run_with_u8s(&mut runner, 5);
assert_eq!(8, output);
assert_fuel_consumed_within_threshold(66_007, fuel_consumed);
assert_fuel_consumed_within_threshold(64_681, fuel_consumed);
Ok(())
}

Expand All @@ -51,7 +51,7 @@ fn test_str(builder: &mut Builder) -> Result<()> {

let (output, _, fuel_consumed) = run(&mut runner, "hello".as_bytes());
assert_eq!("world".as_bytes(), output);
assert_fuel_consumed_within_threshold(142_849, fuel_consumed);
assert_fuel_consumed_within_threshold(146_027, fuel_consumed);
Ok(())
}

Expand Down Expand Up @@ -84,7 +84,7 @@ fn test_logging_with_compile(builder: &mut Builder) -> Result<()> {
"hello world from console.log\nhello world from console.error\n",
logs.as_str(),
);
assert_fuel_consumed_within_threshold(37309, fuel_consumed);
assert_fuel_consumed_within_threshold(36_071, fuel_consumed);
Ok(())
}

Expand All @@ -98,7 +98,7 @@ fn test_logging_without_redirect(builder: &mut Builder) -> Result<()> {
let (output, logs, fuel_consumed) = run(&mut runner, &[]);
assert_eq!(b"hello world from console.log\n".to_vec(), output);
assert_eq!("hello world from console.error\n", logs.as_str());
assert_fuel_consumed_within_threshold(37485, fuel_consumed);
assert_fuel_consumed_within_threshold(36_641, fuel_consumed);
Ok(())
}

Expand All @@ -115,7 +115,7 @@ fn test_logging_with_redirect(builder: &mut Builder) -> Result<()> {
"hello world from console.log\nhello world from console.error\n",
logs.as_str(),
);
assert_fuel_consumed_within_threshold(37309, fuel_consumed);
assert_fuel_consumed_within_threshold(36_042, fuel_consumed);
Ok(())
}

Expand Down Expand Up @@ -177,7 +177,7 @@ fn test_readme_script(builder: &mut Builder) -> Result<()> {

let (output, _, fuel_consumed) = run(&mut runner, r#"{ "n": 2, "bar": "baz" }"#.as_bytes());
assert_eq!(r#"{"foo":3,"newBar":"baz!"}"#.as_bytes(), output);
assert_fuel_consumed_within_threshold(270_919, fuel_consumed);
assert_fuel_consumed_within_threshold(254_503, fuel_consumed);
Ok(())
}

Expand Down Expand Up @@ -223,7 +223,7 @@ fn test_exported_functions(builder: &mut Builder) -> Result<()> {
.build()?;
let (_, logs, fuel_consumed) = run_fn(&mut runner, "foo", &[]);
assert_eq!("Hello from top-level\nHello from foo\n", logs);
assert_fuel_consumed_within_threshold(63_310, fuel_consumed);
assert_fuel_consumed_within_threshold(61_404, fuel_consumed);
let (_, logs, _) = run_fn(&mut runner, "foo-bar", &[]);
assert_eq!("Hello from top-level\nHello from fooBar\n", logs);
Ok(())
Expand Down Expand Up @@ -407,7 +407,7 @@ fn run_fn(r: &mut Runner, func: &str, stdin: &[u8]) -> (Vec<u8>, String, u64) {
fn assert_fuel_consumed_within_threshold(target_fuel: u64, fuel_consumed: u64) {
let target_fuel = target_fuel as f64;
let fuel_consumed = fuel_consumed as f64;
let threshold = 10.0;
let threshold = 2.0;
let percentage_difference = ((fuel_consumed - target_fuel) / target_fuel).abs() * 100.0;

assert!(
Expand Down

0 comments on commit 96a7951

Please sign in to comment.