Skip to content

Commit 0fc20e4

Browse files
wip
1 parent 531e487 commit 0fc20e4

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,27 @@ futures = "0.3.6"
1616

1717
Then you can create a runtime and run typescript using the following code
1818
```rust
19-
let rt = QuickjsRuntimeBuilder::new()
20-
.script_pre_processor(TypeScriptPreProcessor::new())
21-
.build();
19+
use crate::TypeScriptPreProcessor;
20+
use futures::executor::block_on;
21+
use hirofa_utils::js_utils::facades::{JsRuntimeBuilder, JsRuntimeFacade};
22+
use hirofa_utils::js_utils::Script;
23+
use quickjs_runtime::builder::QuickJsRuntimeBuilder;
2224

23-
let fut = rt.js_eval(
24-
None,
25-
Script::new(
26-
"test.ts",
27-
"(function(a: Number, b, c) {let d: String = 'abc'; return(a);}(1, 2, 3))",
28-
),
29-
);
30-
let res = block_on(fut).ok().expect("script failed");
31-
//println!("res = {}", res.js_get_type());
32-
assert_eq!(res.js_as_i32(), 1);
25+
#[test]
26+
fn test_ts() {
27+
let rt = QuickJsRuntimeBuilder::new()
28+
.js_script_pre_processor(TypeScriptPreProcessor::new())
29+
.build();
30+
31+
let fut = rt.js_eval(
32+
None,
33+
Script::new(
34+
"test.ts",
35+
"(function(a: Number, b, c) {let d: String = 'abc'; return(a);}(1, 2, 3))",
36+
),
37+
);
38+
let res = block_on(fut).ok().expect("script failed");
39+
//println!("res = {}", res.js_get_type());
40+
assert_eq!(res.get_i32(), 1);
41+
}
3342
```

0 commit comments

Comments
 (0)