-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from fossil-engineering/feat/re-export-runtime
- Loading branch information
Showing
3 changed files
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use deno_runner::{Builder, Runtime}; | ||
use std::collections::HashMap; | ||
|
||
#[test] | ||
fn test_tokio_runtime() { | ||
// Using re-exported tokio runtime | ||
let rt = Runtime::new().unwrap(); | ||
let out = rt.block_on(async { | ||
let custom_code = r#" | ||
const add = (a, b) => a + b; | ||
add(a, b) | ||
"#; | ||
|
||
let runner = Builder::new().build(); | ||
let vars = HashMap::from([("a", 1), ("b", 2)]); | ||
let result = runner.run(custom_code, Some(vars)).await.unwrap(); | ||
|
||
result | ||
}); | ||
|
||
assert_eq!(out, "3"); | ||
} |