fix(napi): invalid memory address in FromNapiValue for &str
This commit is contained in:
parent
645a2e7885
commit
2de500f33b
6 changed files with 36 additions and 2 deletions
examples/napi
|
@ -100,6 +100,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
name: string␊
|
||||
}␊
|
||||
export function receiveStrictObject(strictObject: StrictObject): void␊
|
||||
export function getStrFromObject(): void␊
|
||||
export function asyncPlus100(p: Promise<number>): Promise<number>␊
|
||||
/** This is an interface for package.json */␊
|
||||
export interface PackageJson {␊
|
||||
|
|
Binary file not shown.
|
@ -76,6 +76,7 @@ import {
|
|||
receiveClassOrNumber,
|
||||
JsClassForEither,
|
||||
receiveMutClassOrNumber,
|
||||
getStrFromObject,
|
||||
} from '../'
|
||||
|
||||
test('export const', (t) => {
|
||||
|
@ -197,6 +198,10 @@ test('object', (t) => {
|
|||
t.deepEqual(createObj(), { test: 1 })
|
||||
})
|
||||
|
||||
test('get str from object', (t) => {
|
||||
t.notThrows(() => getStrFromObject())
|
||||
})
|
||||
|
||||
test('global', (t) => {
|
||||
t.is(getGlobal(), global)
|
||||
})
|
||||
|
|
1
examples/napi/index.d.ts
vendored
1
examples/napi/index.d.ts
vendored
|
@ -90,6 +90,7 @@ export interface StrictObject {
|
|||
name: string
|
||||
}
|
||||
export function receiveStrictObject(strictObject: StrictObject): void
|
||||
export function getStrFromObject(): void
|
||||
export function asyncPlus100(p: Promise<number>): Promise<number>
|
||||
/** This is an interface for package.json */
|
||||
export interface PackageJson {
|
||||
|
|
|
@ -69,3 +69,10 @@ pub struct StrictObject {
|
|||
pub fn receive_strict_object(strict_object: StrictObject) {
|
||||
assert_eq!(strict_object.name, "strict");
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn get_str_from_object(env: Env) {
|
||||
let mut obj = env.create_object().unwrap();
|
||||
obj.set("name", "value").unwrap();
|
||||
assert_eq!(obj.get("name").unwrap(), Some("value"));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue