forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(napi): Cleanup tests (denoland#17347)
- Loading branch information
1 parent
e26fc19
commit d0a53c3
Showing
13 changed files
with
342 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,33 @@ | ||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. | ||
|
||
use napi_sys::Status::napi_ok; | ||
use crate::assert_napi_ok; | ||
use crate::napi_get_callback_info; | ||
use crate::napi_new_property; | ||
use napi_sys::*; | ||
|
||
extern "C" fn test_detached( | ||
env: napi_env, | ||
info: napi_callback_info, | ||
) -> napi_value { | ||
let (args, argc, _) = crate::get_callback_info!(env, info, 1); | ||
let (args, argc, _) = napi_get_callback_info!(env, info, 1); | ||
assert_eq!(argc, 1); | ||
|
||
let mut value = false; | ||
assert!( | ||
unsafe { napi_is_detached_arraybuffer(env, args[0], &mut value) } | ||
== napi_ok | ||
); | ||
assert_napi_ok!(napi_is_detached_arraybuffer(env, args[0], &mut value)); | ||
assert!(!value); | ||
assert!(unsafe { napi_detach_arraybuffer(env, args[0]) } == napi_ok); | ||
assert!( | ||
unsafe { napi_is_detached_arraybuffer(env, args[0], &mut value) } | ||
== napi_ok | ||
); | ||
assert_napi_ok!(napi_detach_arraybuffer(env, args[0])); | ||
assert_napi_ok!(napi_is_detached_arraybuffer(env, args[0], &mut value)); | ||
assert!(value); | ||
args[0] | ||
} | ||
|
||
pub fn init(env: napi_env, exports: napi_value) { | ||
let properties = | ||
&[crate::new_property!(env, "test_detached\0", test_detached)]; | ||
let properties = &[napi_new_property!(env, "test_detached", test_detached)]; | ||
|
||
unsafe { | ||
napi_define_properties(env, exports, properties.len(), properties.as_ptr()) | ||
}; | ||
assert_napi_ok!(napi_define_properties( | ||
env, | ||
exports, | ||
properties.len(), | ||
properties.as_ptr() | ||
)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.