From 4bb1a34abbb63df680b1c63d950828e829855cce Mon Sep 17 00:00:00 2001 From: Ilya Lakhin Date: Tue, 15 Sep 2020 10:03:46 +0700 Subject: [PATCH 1/6] Fixes bug in Module::set_fn_4_mut --- src/module.rs | 2 +- tests/modules.rs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/module.rs b/src/module.rs index 3513dd7f..4d70b169 100644 --- a/src/module.rs +++ b/src/module.rs @@ -913,7 +913,7 @@ impl Module { TypeId::of::(), TypeId::of::(), TypeId::of::(), - TypeId::of::(), + TypeId::of::(), ]; self.set_fn(name, Public, &arg_types, Func::from_method(Box::new(f))) } diff --git a/tests/modules.rs b/tests/modules.rs index 06f5e37e..0744fd8c 100644 --- a/tests/modules.rs +++ b/tests/modules.rs @@ -78,6 +78,15 @@ fn test_module_resolver() -> Result<(), Box> { Ok(()) }); + #[cfg(not(feature = "no_float"))] + module.set_fn_4_mut( + "sum_of_three_args".to_string(), + |target: &mut INT, a: INT, b: INT, c: f64| { + *target = a + b + c as INT; + Ok(()) + } + ); + resolver.insert("hello", module); let mut engine = Engine::new(); @@ -130,6 +139,20 @@ fn test_module_resolver() -> Result<(), Box> { )?, 42 ); + #[cfg(not(feature = "no_float"))] + { + assert_eq!( + engine.eval::( + r#" + import "hello" as h; + let x = 21; + h::sum_of_three_args(x, 14, 26, 2.0); + x + "# + )?, + 42 + ); + } #[cfg(not(feature = "unchecked"))] { From 29124a8543632c2b3e32a48e3cdfc9f349ed2568 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 15 Sep 2020 12:14:57 +0800 Subject: [PATCH 2/6] Restore benchmark.yml. --- .github/workflows/benchmark.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/benchmark.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000..df310705 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,29 @@ +name: Benchmark +on: + push: + branches: + - master + +jobs: + benchmark: + name: Run Rust benchmark + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup toolchain update nightly && rustup default nightly + - name: Run benchmark + run: cargo +nightly bench | tee output.txt + - name: Store benchmark result + uses: rhysd/github-action-benchmark@v1 + with: + name: Rust Benchmark + tool: 'cargo' + output-file-path: output.txt + # Use personal access token instead of GITHUB_TOKEN due to https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false + github-token: ${{ secrets.RHAI }} + auto-push: true + # Show alert with commit comment on detecting possible performance regression + alert-threshold: '200%' + comment-on-alert: true + fail-on-alert: true + alert-comment-cc-users: '@schungx' From 83a2b401075d1ad508e9f76f1b34241e4def0e42 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 15 Sep 2020 12:19:26 +0800 Subject: [PATCH 3/6] Delete benchmark.yml --- .github/workflows/benchmark.yml | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 .github/workflows/benchmark.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index df310705..00000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Benchmark -on: - push: - branches: - - master - -jobs: - benchmark: - name: Run Rust benchmark - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: rustup toolchain update nightly && rustup default nightly - - name: Run benchmark - run: cargo +nightly bench | tee output.txt - - name: Store benchmark result - uses: rhysd/github-action-benchmark@v1 - with: - name: Rust Benchmark - tool: 'cargo' - output-file-path: output.txt - # Use personal access token instead of GITHUB_TOKEN due to https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false - github-token: ${{ secrets.RHAI }} - auto-push: true - # Show alert with commit comment on detecting possible performance regression - alert-threshold: '200%' - comment-on-alert: true - fail-on-alert: true - alert-comment-cc-users: '@schungx' From 7f8269c288b82e80530f6274657b96598f54ea64 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 15 Sep 2020 12:21:51 +0800 Subject: [PATCH 4/6] Add bug fixes. --- RELEASES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 902cd855..cb155381 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4,6 +4,12 @@ Rhai Release Notes Version 0.19.0 ============== +Bug fixes +--------- + +* `if` statement with an empty `true` block would not evaluate the `false` block. This is now fixed. +* Fixes a bug in `Module::set_fn_4_mut`. + New features ------------ From b0d86d8bf2effa2ec65f438685374fb7bcab22be Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 15 Sep 2020 12:23:57 +0800 Subject: [PATCH 5/6] Revert "Delete benchmark.yml" This reverts commit 83a2b401075d1ad508e9f76f1b34241e4def0e42. --- .github/workflows/benchmark.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/benchmark.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000..df310705 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,29 @@ +name: Benchmark +on: + push: + branches: + - master + +jobs: + benchmark: + name: Run Rust benchmark + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup toolchain update nightly && rustup default nightly + - name: Run benchmark + run: cargo +nightly bench | tee output.txt + - name: Store benchmark result + uses: rhysd/github-action-benchmark@v1 + with: + name: Rust Benchmark + tool: 'cargo' + output-file-path: output.txt + # Use personal access token instead of GITHUB_TOKEN due to https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false + github-token: ${{ secrets.RHAI }} + auto-push: true + # Show alert with commit comment on detecting possible performance regression + alert-threshold: '200%' + comment-on-alert: true + fail-on-alert: true + alert-comment-cc-users: '@schungx' From d547562c14df13f32ae4876f5b3b30cec4276ac3 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 15 Sep 2020 12:29:10 +0800 Subject: [PATCH 6/6] Delete benchmark.yml --- .github/workflows/benchmark.yml | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 .github/workflows/benchmark.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index df310705..00000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Benchmark -on: - push: - branches: - - master - -jobs: - benchmark: - name: Run Rust benchmark - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: rustup toolchain update nightly && rustup default nightly - - name: Run benchmark - run: cargo +nightly bench | tee output.txt - - name: Store benchmark result - uses: rhysd/github-action-benchmark@v1 - with: - name: Rust Benchmark - tool: 'cargo' - output-file-path: output.txt - # Use personal access token instead of GITHUB_TOKEN due to https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false - github-token: ${{ secrets.RHAI }} - auto-push: true - # Show alert with commit comment on detecting possible performance regression - alert-threshold: '200%' - comment-on-alert: true - fail-on-alert: true - alert-comment-cc-users: '@schungx'