mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 18:20:51 +00:00
webidl: add int const test
This commit is contained in:
parent
88f0e84f6c
commit
473ac6d2ee
@ -42,3 +42,88 @@ fn bool() {
|
||||
)
|
||||
.test();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ints() {
|
||||
project()
|
||||
.file(
|
||||
"foo.webidl",
|
||||
r#"
|
||||
interface Byte {
|
||||
const byte imin = -128;
|
||||
const byte imax = 127;
|
||||
const octet umin = 0;
|
||||
const octet umax = 255;
|
||||
};
|
||||
interface Short {
|
||||
const short imin = -32768;
|
||||
const short imax = 32767;
|
||||
const unsigned short umin = 0;
|
||||
const unsigned short umax = 65535;
|
||||
};
|
||||
interface Long {
|
||||
const long imin = -2147483648;
|
||||
const long imax = 2147483647;
|
||||
const unsigned long umin = 0;
|
||||
const unsigned long umax = 4294967295;
|
||||
};
|
||||
interface LongLong {
|
||||
const long long imin = -9223372036854775808;
|
||||
const long long imax = 9223372036854775807;
|
||||
const unsigned long long umin = 0;
|
||||
// bug in webidl
|
||||
// https://github.com/sgodwincs/webidl-rs/issues/15
|
||||
//const unsigned long long umax = 18446744073709551615;
|
||||
};
|
||||
"#,
|
||||
)
|
||||
// a corresponding const in the js implementation is not required
|
||||
// value is taken directly from idl
|
||||
.file(
|
||||
"foo.js",
|
||||
r#"
|
||||
export class Byte {
|
||||
}
|
||||
export class Short {
|
||||
}
|
||||
export class Long {
|
||||
}
|
||||
export class LongLong {
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
r#"
|
||||
#![feature(proc_macro, wasm_custom_section, wasm_import_module)]
|
||||
extern crate wasm_bindgen;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
pub mod foo;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn test() {
|
||||
assert_eq!(foo::Byte::IMIN, i8::min_value());
|
||||
assert_eq!(foo::Byte::IMAX, i8::max_value());
|
||||
assert_eq!(foo::Byte::UMIN, u8::min_value());
|
||||
assert_eq!(foo::Byte::UMAX, u8::max_value());
|
||||
|
||||
assert_eq!(foo::Short::IMIN, i16::min_value());
|
||||
assert_eq!(foo::Short::IMAX, i16::max_value());
|
||||
assert_eq!(foo::Short::UMIN, u16::min_value());
|
||||
assert_eq!(foo::Short::UMAX, u16::max_value());
|
||||
|
||||
assert_eq!(foo::Long::IMIN, i32::min_value());
|
||||
assert_eq!(foo::Long::IMAX, i32::max_value());
|
||||
assert_eq!(foo::Long::UMIN, u32::min_value());
|
||||
assert_eq!(foo::Long::UMAX, u32::max_value());
|
||||
|
||||
assert_eq!(foo::LongLong::IMIN, i64::min_value());
|
||||
assert_eq!(foo::LongLong::IMAX, i64::max_value());
|
||||
assert_eq!(foo::LongLong::UMIN, u64::min_value());
|
||||
//assert_eq!(foo::LongLong::UMAX, u64::max_value());
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.test();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user