From 39ca831ab7ccc72d919e11a3ebbed291f50daf15 Mon Sep 17 00:00:00 2001 From: zhaojunxia Date: Tue, 17 May 2022 11:21:38 +0800 Subject: [PATCH] add storytest Signed-off-by: zhaojunxia --- src/gen/generate/param_generate.js | 5 +- test/storytest/{test_direct => }/basic.d.ts | 60 +++++++++---------- test/storytest/test.py | 6 +- .../basic.d.ts => test_$/@ohos.test.d.ts} | 51 +++++++--------- test/storytest/test_$/test.js | 26 ++++++++ .../basic.d.ts => test_[]/@ohos.test.d.ts} | 53 +++++++--------- test/storytest/test_[]/test.js | 39 ++++++++++++ .../basic.d.ts => test_array/@ohos.test.d.ts} | 53 +++++++--------- test/storytest/test_array/test.js | 41 +++++++++++++ test/storytest/test_bool/@ohos.test.d.ts | 21 +++++++ test/storytest/test_bool/test.js | 25 ++++++++ test/storytest/test_direct/@ohos.test.d.ts | 4 +- test/storytest/test_interface/@ohos.test.d.ts | 4 +- test/storytest/test_interface/test.js | 12 ++-- test/storytest/test_namespace/@ohos.test.d.ts | 4 +- test/storytest/test_number/@ohos.test.d.ts | 2 +- test/storytest/test_number/test.js | 6 +- test/storytest/test_static/@ohos.test.d.ts | 23 +++++++ test/storytest/test_static/test.js | 32 ++++++++++ test/storytest/test_string/@ohos.test.d.ts | 2 +- test/storytest/test_string/basic.d.ts | 30 ---------- 21 files changed, 326 insertions(+), 173 deletions(-) rename test/storytest/{test_direct => }/basic.d.ts (96%) mode change 100755 => 100644 rename test/storytest/{test_interface/basic.d.ts => test_$/@ohos.test.d.ts} (66%) mode change 100755 => 100644 create mode 100644 test/storytest/test_$/test.js rename test/storytest/{test_namespace/basic.d.ts => test_[]/@ohos.test.d.ts} (66%) mode change 100755 => 100644 create mode 100644 test/storytest/test_[]/test.js rename test/storytest/{test_number/basic.d.ts => test_array/@ohos.test.d.ts} (66%) mode change 100755 => 100644 create mode 100644 test/storytest/test_array/test.js create mode 100644 test/storytest/test_bool/@ohos.test.d.ts create mode 100644 test/storytest/test_bool/test.js create mode 100644 test/storytest/test_static/@ohos.test.d.ts create mode 100644 test/storytest/test_static/test.js delete mode 100755 test/storytest/test_string/basic.d.ts diff --git a/src/gen/generate/param_generate.js b/src/gen/generate/param_generate.js index b22ff126..9d9afdce 100644 --- a/src/gen/generate/param_generate.js +++ b/src/gen/generate/param_generate.js @@ -131,7 +131,6 @@ function paramGenerateArray(p, name, type, param) { } else { NapiLog.logError("The current version do not support to this param to generate :", name, "type :", type); } - return param } // 函数的参数处理 @@ -142,7 +141,7 @@ function paramGenerate(p, name, type, param, data) { param.valueFill += "%svio->in%d".format(param.valueFill.length > 0 ? ", " : "", p) param.valueDefine += "%sstd::string &%s".format(param.valueDefine.length > 0 ? ", " : "", name) } - else if (type.substring(0, 12) == "NUMBER_TYPE_") { + else if (type.substring(0, 12) == "NUMBER_TYPE_" && type.indexOf("[]") < 0) { param.valueIn += "\n %s in%d;".format(type, p) param.valueCheckout += jsToC("vio->in" + p, "pxt->GetArgv(%d)".format(p), type) param.valueFill += "%svio->in%d".format(param.valueFill.length > 0 ? ", " : "", p) @@ -167,7 +166,7 @@ function paramGenerate(p, name, type, param, data) { param.valueFill += "%svio->in%d".format(param.valueFill.length > 0 ? ", " : "", p) param.valueDefine += "%sbool &%s".format(param.valueDefine.length > 0 ? ", " : "", name) } else { - param = paramGenerateArray(p, name, type, param); + paramGenerateArray(p, name, type, param); } } module.exports = { diff --git a/test/storytest/test_direct/basic.d.ts b/test/storytest/basic.d.ts old mode 100755 new mode 100644 similarity index 96% rename from test/storytest/test_direct/basic.d.ts rename to test/storytest/basic.d.ts index 7ad3b63c..eccee7c5 --- a/test/storytest/test_direct/basic.d.ts +++ b/test/storytest/basic.d.ts @@ -1,30 +1,30 @@ -/* -* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -export interface Callback { - (data: T): void; -} - -export interface ErrorCallback { - (err: T): void; -} - -export interface AsyncCallback { - (err: BusinessError, data: T): void; -} - -export interface BusinessError extends Error { - code: number; -} +/* +* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +export interface Callback { + (data: T): void; +} + +export interface ErrorCallback { + (err: T): void; +} + +export interface AsyncCallback { + (err: BusinessError, data: T): void; +} + +export interface BusinessError extends Error { + code: number; +} diff --git a/test/storytest/test.py b/test/storytest/test.py index 9cabcf8e..39918261 100755 --- a/test/storytest/test.py +++ b/test/storytest/test.py @@ -15,11 +15,11 @@ def do_test(): return if not os.path.exists("out"): os.mkdir("out") - ret=os.popen("node ../../../src/gen/cmd_gen.js -f @ohos.test.d.ts -o ./out") + ret = os.popen("node ../../../src/gen/cmd_gen.js -f @ohos.test.d.ts -o ./out") print(ret.read()) os.chdir("out") - ret=os.popen("npx node-gyp configure build") + ret = os.popen("npx node-gyp configure build") os.chdir("..") if "COPY Release" not in ret.read(): @@ -35,7 +35,7 @@ if __name__ == "__main__": work_path = os.path.split(sys.argv[0])[0] os.chdir(work_path) - if len(sys.argv)>=2: + if len(sys.argv) >= 2: for fn in sys.argv[1:]: if os.path.isdir(fn): os.chdir(fn) diff --git a/test/storytest/test_interface/basic.d.ts b/test/storytest/test_$/@ohos.test.d.ts old mode 100755 new mode 100644 similarity index 66% rename from test/storytest/test_interface/basic.d.ts rename to test/storytest/test_$/@ohos.test.d.ts index 7ad3b63c..f64c1aa9 --- a/test/storytest/test_interface/basic.d.ts +++ b/test/storytest/test_$/@ohos.test.d.ts @@ -1,30 +1,21 @@ -/* -* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -export interface Callback { - (data: T): void; -} - -export interface ErrorCallback { - (err: T): void; -} - -export interface AsyncCallback { - (err: BusinessError, data: T): void; -} - -export interface BusinessError extends Error { - code: number; -} +/* +* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback, Callback } from './../basic'; + +declare namespace napitest { + function $fun1(v: string): string; +} + +export default napitest; diff --git a/test/storytest/test_$/test.js b/test/storytest/test_$/test.js new file mode 100644 index 00000000..62cb6717 --- /dev/null +++ b/test/storytest/test_$/test.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +const { $fun1 } = require("./out/build/Release/napitest") +var assert = require("assert"); + +describe('String', function () { + + it('test $fun1', function () { + let ret = $fun1("1"); + assert.strictEqual(ret, ''); + }); + +}); + diff --git a/test/storytest/test_namespace/basic.d.ts b/test/storytest/test_[]/@ohos.test.d.ts old mode 100755 new mode 100644 similarity index 66% rename from test/storytest/test_namespace/basic.d.ts rename to test/storytest/test_[]/@ohos.test.d.ts index 7ad3b63c..53d2efa0 --- a/test/storytest/test_namespace/basic.d.ts +++ b/test/storytest/test_[]/@ohos.test.d.ts @@ -1,30 +1,23 @@ -/* -* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -export interface Callback { - (data: T): void; -} - -export interface ErrorCallback { - (err: T): void; -} - -export interface AsyncCallback { - (err: BusinessError, data: T): void; -} - -export interface BusinessError extends Error { - code: number; -} +/* +* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback, Callback } from './../basic'; + +declare namespace napitest { + function fun1(v1: string[]): number; + function fun2(v1: number[]): number; + function fun3(v1: boolean[]): number; +} + +export default napitest; diff --git a/test/storytest/test_[]/test.js b/test/storytest/test_[]/test.js new file mode 100644 index 00000000..1ca45d47 --- /dev/null +++ b/test/storytest/test_[]/test.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +const { fun1, fun2, fun3, fun4 } = require("./out/build/Release/napitest") +var assert = require("assert"); + +describe('String', function () { + var GrantStatus = { + PERMISSION_DENIED: -1, + PERMISSION_GRANTED: 2, + PERMISSION_PASS: 3 + } + it('test fun1', function () { + let ret = fun1(['a', 'b', 'c', 'd']); + assert.strictEqual(ret, 0); + }); + + it('test fun2', function () { + let ret = fun2([1, 2, 3, 4]); + assert.strictEqual(ret, 0); + }); + + it('test fun3', function () { + let ret = fun3([true, true, false, false]); + assert.strictEqual(ret, 0); + }); +}); + diff --git a/test/storytest/test_number/basic.d.ts b/test/storytest/test_array/@ohos.test.d.ts old mode 100755 new mode 100644 similarity index 66% rename from test/storytest/test_number/basic.d.ts rename to test/storytest/test_array/@ohos.test.d.ts index 7ad3b63c..2d882817 --- a/test/storytest/test_number/basic.d.ts +++ b/test/storytest/test_array/@ohos.test.d.ts @@ -1,30 +1,23 @@ -/* -* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -export interface Callback { - (data: T): void; -} - -export interface ErrorCallback { - (err: T): void; -} - -export interface AsyncCallback { - (err: BusinessError, data: T): void; -} - -export interface BusinessError extends Error { - code: number; -} +/* +* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback, Callback } from './../basic'; + +declare namespace napitest { + function fun1(v1: Array): number; + function fun2(v1: Array): number; + function fun3(v1: Array): number; +} + +export default napitest; diff --git a/test/storytest/test_array/test.js b/test/storytest/test_array/test.js new file mode 100644 index 00000000..9dc459b7 --- /dev/null +++ b/test/storytest/test_array/test.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +const { fun1, fun2, fun3, fun4 } = require("./out/build/Release/napitest") +var assert = require("assert"); + +describe('String', function () { + var GrantStatus = { + PERMISSION_DENIED: -1, + PERMISSION_GRANTED: 2, + PERMISSION_PASS: 3 + } + + it('test fun1', function () { + let ret = fun1(['a', 'b', 'c', 'd']); + assert.strictEqual(ret, 0); + }); + + it('test fun2', function () { + let ret = fun2([1, 2, 3, 4]); + assert.strictEqual(ret, 0); + }); + + it('test fun3', function () { + let ret = fun3([true, true, true, true]); + assert.strictEqual(ret, 0); + }); + +}); + diff --git a/test/storytest/test_bool/@ohos.test.d.ts b/test/storytest/test_bool/@ohos.test.d.ts new file mode 100644 index 00000000..c7f32c66 --- /dev/null +++ b/test/storytest/test_bool/@ohos.test.d.ts @@ -0,0 +1,21 @@ +/* +* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback, Callback } from './../basic'; + +declare namespace napitest { + function fun1(v: boolean): boolean; +} + +export default napitest; diff --git a/test/storytest/test_bool/test.js b/test/storytest/test_bool/test.js new file mode 100644 index 00000000..df7b6ea1 --- /dev/null +++ b/test/storytest/test_bool/test.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +const { fun1 } = require("./out/build/Release/napitest") +var assert = require("assert"); + +describe('boolean', function () { + it('test fun1', function () { + let ret = fun1(true); + assert.strictEqual(ret, 0); + }); + +}); + diff --git a/test/storytest/test_direct/@ohos.test.d.ts b/test/storytest/test_direct/@ohos.test.d.ts index ac45f57f..1091989a 100755 --- a/test/storytest/test_direct/@ohos.test.d.ts +++ b/test/storytest/test_direct/@ohos.test.d.ts @@ -12,13 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { AsyncCallback, Callback } from './basic'; +import { AsyncCallback, Callback } from './../basic'; declare namespace napitest { export interface Result { code: number; data: string; - } + } interface TestClass1 { num1: number; diff --git a/test/storytest/test_interface/@ohos.test.d.ts b/test/storytest/test_interface/@ohos.test.d.ts index e890ebdf..b1c7e8a1 100755 --- a/test/storytest/test_interface/@ohos.test.d.ts +++ b/test/storytest/test_interface/@ohos.test.d.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { AsyncCallback, Callback } from './basic'; +import { AsyncCallback, Callback } from './../basic'; declare namespace napitest { interface Human { @@ -25,7 +25,7 @@ declare namespace napitest { num1: number; fun1(v: number): number; fun2(numcc: Array, mancc: Human): Human; - fun3(v: number):boolean; + fun3(v: number): boolean; fun4(v2: string, mancc: Array): Human; } } diff --git a/test/storytest/test_interface/test.js b/test/storytest/test_interface/test.js index 6abafc01..fe027d96 100755 --- a/test/storytest/test_interface/test.js +++ b/test/storytest/test_interface/test.js @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const { TestClass1,TestClass2 } = require("./out/build/Release/napitest") +const { TestClass1 } = require("./out/build/Release/napitest") const test = require("./out/build/Release/napitest") var assert = require("assert"); const { consumers } = require("stream"); @@ -27,22 +27,22 @@ describe('Interface', function () { it('test TestClass1 fun2', function () { let tc = new TestClass1(); - let ret = tc.fun2([1,2,3],{name:'haha',age:20}); - let retJson=JSON.stringify(ret); + let ret = tc.fun2([1, 2, 3], { name: 'haha', age: 20 }); + let retJson = JSON.stringify(ret); assert.strictEqual(retJson, '{"name":"","age":0}'); }); it('test TestClass1 fun3', function () { let tc = new TestClass1(); let ret = tc.fun3(2); - let retJson=JSON.stringify(ret); + let retJson = JSON.stringify(ret); assert.strictEqual(retJson, '0'); }); it('test TestClass1 fun4', function () { let tc = new test.TestClass1(); - let ret = tc.fun4('aaa',[{name:'haha',age:20},{name:'houhou',age:23}]); - let retJson=JSON.stringify(ret); + let ret = tc.fun4('aaa', [{ name: 'haha', age: 20 }, { name: 'houhou', age: 23 }]); + let retJson = JSON.stringify(ret); assert.strictEqual(retJson, '{"name":"","age":0}'); }); }); diff --git a/test/storytest/test_namespace/@ohos.test.d.ts b/test/storytest/test_namespace/@ohos.test.d.ts index 1ceddce8..127fd189 100755 --- a/test/storytest/test_namespace/@ohos.test.d.ts +++ b/test/storytest/test_namespace/@ohos.test.d.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { AsyncCallback, Callback } from './basic'; +import { AsyncCallback, Callback } from './../basic'; declare namespace napitest { namespace Space3 { @@ -23,7 +23,7 @@ declare namespace napitest { } interface TestClass2 { animal: Animal; - fix(v1:string):string; + fix(v1: string): string; fun2(numcc: Array, animalcc: Animal): Animal; } } diff --git a/test/storytest/test_number/@ohos.test.d.ts b/test/storytest/test_number/@ohos.test.d.ts index 2e31b21d..aac67663 100755 --- a/test/storytest/test_number/@ohos.test.d.ts +++ b/test/storytest/test_number/@ohos.test.d.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { AsyncCallback, Callback } from './basic'; +import { AsyncCallback, Callback } from './../basic'; declare namespace napitest { interface TestClass1 { diff --git a/test/storytest/test_number/test.js b/test/storytest/test_number/test.js index 913327ea..dc564d34 100755 --- a/test/storytest/test_number/test.js +++ b/test/storytest/test_number/test.js @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -const { fun1, fun2, fun3,fun4,fun5 } = require("./out/build/Release/napitest") +const { fun1, fun2, fun3, fun4, fun5 } = require("./out/build/Release/napitest") var assert = require("assert"); describe('Number', function () { @@ -39,7 +39,7 @@ describe('Number', function () { }); it('test fun4', function () { - fun4('aaa',abc); + fun4('aaa', abc); }); function def(ret) { @@ -47,7 +47,7 @@ describe('Number', function () { } it('test fun5', function () { - fun5(12,def); + fun5(12, def); //fun5(12).then(def); }); diff --git a/test/storytest/test_static/@ohos.test.d.ts b/test/storytest/test_static/@ohos.test.d.ts new file mode 100644 index 00000000..b74f2c7b --- /dev/null +++ b/test/storytest/test_static/@ohos.test.d.ts @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import { AsyncCallback, Callback } from './../basic'; + +declare namespace napitest { + class Person { + static getMaxAge(v1: string): number; + } +} + +export default napitest; diff --git a/test/storytest/test_static/test.js b/test/storytest/test_static/test.js new file mode 100644 index 00000000..1c0f9340 --- /dev/null +++ b/test/storytest/test_static/test.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +const { Person } = require("./out/build/Release/napitest") +const test = require("./out/build/Release/napitest") +var assert = require("assert"); +const { consumers } = require("stream"); + +describe('class static', function () { + + it('test PersonClass fun1', function () { + let person = new Person(); + let ret = person.getMaxAge('20'); + assert.strictEqual(ret, 0); + }); +}); + + + + + diff --git a/test/storytest/test_string/@ohos.test.d.ts b/test/storytest/test_string/@ohos.test.d.ts index 2d382205..8d3634e5 100755 --- a/test/storytest/test_string/@ohos.test.d.ts +++ b/test/storytest/test_string/@ohos.test.d.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { AsyncCallback, Callback } from './basic'; +import { AsyncCallback, Callback } from './../basic'; declare namespace napitest { interface TestClass1 { diff --git a/test/storytest/test_string/basic.d.ts b/test/storytest/test_string/basic.d.ts deleted file mode 100755 index 7ad3b63c..00000000 --- a/test/storytest/test_string/basic.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* -* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -export interface Callback { - (data: T): void; -} - -export interface ErrorCallback { - (err: T): void; -} - -export interface AsyncCallback { - (err: BusinessError, data: T): void; -} - -export interface BusinessError extends Error { - code: number; -} -- Gitee