Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposing Value::TypeOf #1133

Merged
merged 6 commits into from Nov 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#957 including test case
  • Loading branch information
Mike Mulchrone committed Nov 26, 2022
commit 59f0ab4705c6d46d200a647dff2bbc0e5c960620
20 changes: 20 additions & 0 deletions tests/test_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4424,6 +4424,25 @@ fn shared_array_buffer() {
}
}

#[test]
fn typeof_checker() {
let _setup_guard = setup();

let isolate = &mut v8::Isolate::new(Default::default());
let scope = &mut v8::HandleScope::new(isolate);
let context = v8::Context::new(scope);
let scope = &mut v8::ContextScope::new(scope, context);

let value_1 = eval(scope, "").unwrap();
let type_of = value_1.type_of(scope);
let value_2 = eval(scope, "").unwrap();
let type_of_2 = value_2.type_of(scope);
assert_eq!(type_of, type_of_2);
let value_3 = eval(scope,"1").unwrap();
let type_of_3 = value_3.type_of(scope);
assert_ne!(type_of_2, type_of_3);
}

#[test]
#[allow(clippy::cognitive_complexity)]
#[allow(clippy::eq_op)]
Expand Down Expand Up @@ -4460,6 +4479,7 @@ fn value_checker() {
assert!(value.to_boolean(scope) == v8::Boolean::new(scope, false));
assert!(!value.boolean_value(scope));


let value = eval(scope, "true").unwrap();
assert!(value.is_boolean());
assert!(value.is_true());
Expand Down