1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use wasm_bindgen::prelude::*;
pub struct Node {}
#[wasm_bindgen]
extern "C" {
type NodeError;
#[wasm_bindgen(method, getter, js_class = "Error", structural)]
fn stack(this: &NodeError) -> String;
}
impl Node {
pub fn new() -> Option<Node> {
if super::detect::is_browser() {
return None;
}
Some(Node {})
}
}
impl super::Formatter for Node {
fn writeln(&self, line: &str) {
super::js_console_log(line);
}
fn log_test(&self, name: &str, result: &Result<(), JsValue>) {
let s = if result.is_ok() { "ok" } else { "FAIL" };
self.writeln(&format!("test {} ... {}", name, s));
}
fn stringify_error(&self, err: &JsValue) -> String {
NodeError::from(err.clone()).stack()
}
}