File: meter_element.rs

package info (click to toggle)
rustc-web 1.78.0%2Bdfsg1-2~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,245,420 kB
  • sloc: xml: 147,985; javascript: 18,022; sh: 11,083; python: 10,265; ansic: 6,172; cpp: 5,023; asm: 4,390; makefile: 4,269
file content (56 lines) | stat: -rw-r--r-- 1,191 bytes parent folder | download | duplicates (5)
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
46
47
48
49
50
51
52
53
54
55
56
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
use web_sys::HtmlMeterElement;

#[wasm_bindgen(module = "/tests/wasm/element.js")]
extern "C" {
    fn new_meter() -> HtmlMeterElement;
}

#[wasm_bindgen_test]
fn test_meter_element() {
    let meter = new_meter();

    meter.set_min(-5.);
    assert_eq!(
        meter.min(),
        -5.,
        "Meter should have the min value we gave it."
    );

    meter.set_max(5.);
    assert_eq!(
        meter.max(),
        5.,
        "Meter should have the max value we gave it."
    );

    meter.set_value(2.);
    assert_eq!(meter.value(), 2., "Meter should have the value we gave it.");

    meter.set_low(-1.);
    assert_eq!(
        meter.low(),
        -1.,
        "Meter should have the low value we gave it."
    );

    meter.set_high(1.);
    assert_eq!(
        meter.high(),
        1.,
        "Meter should have the high value we gave it."
    );

    meter.set_optimum(3.);
    assert_eq!(
        meter.optimum(),
        3.,
        "Meter should have the optimum value we gave it."
    );

    assert!(
        meter.labels().length() == 0,
        "Our meter shouldn't have any labels associated with it."
    );
}