javascript 0.3.0

A JavaScript engine implementation in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use javascript::*;

#[test]
fn debug_boxed_prototype_identity() {
    let script = r#"
        // Attach a marker to Number.prototype and inspect the boxed object's prototype
        Number.prototype.__marker = 'NUM_PROTO_MARKER';
        const boxed = Object(123);
        const protoMarker = boxed.__proto__ && boxed.__proto__.__marker;
        const ctorMarker = Number.prototype.__marker;
        const eq = boxed.__proto__ === Number.prototype;
        protoMarker + '|' + ctorMarker + '|' + (eq ? 'EQ' : 'NEQ');
    "#;

    let res = evaluate_script(script, false, None::<&std::path::Path>).unwrap();
    assert_eq!(res, "\"NUM_PROTO_MARKER|NUM_PROTO_MARKER|EQ\"");
}