提交 09dbdce3 编写于 作者: 雪洛's avatar 雪洛

feat: 调整示例兼容web端,屏蔽不兼容web的示例

上级 c1905652
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, }
// #ifndef WEB
,
{ {
"path": "pages/advance/advance", "path": "pages/advance/advance",
"style": { "style": {
...@@ -171,6 +173,7 @@ ...@@ -171,6 +173,7 @@
} }
} }
// #endif
], ],
"tabBar": { "tabBar": {
......
...@@ -20,9 +20,7 @@ ...@@ -20,9 +20,7 @@
<!-- #endif --> <!-- #endif -->
</template> </template>
<script lang="ts"> <script lang="ts">
// #ifdef APP
import { runTests, Result } from '../../uni_modules/uts-tests' import { runTests, Result } from '../../uni_modules/uts-tests'
// #endif
export default { export default {
data() { data() {
return { return {
......
...@@ -16,12 +16,12 @@ export function testArray(): Result { ...@@ -16,12 +16,12 @@ export function testArray(): Result {
// swift 中字面量创建数组,仅支持同一类型的元素 // swift 中字面量创建数组,仅支持同一类型的元素
// #ifndef APP-IOS // #ifndef APP-IOS
expect(a3).toEqual(new Array(1,2,3)); expect(a3).toEqual(new Array(1,2,3));
let a4 = new Array(1,'2',3); let a4 = new Array<any>(1,'2',3);
expect(a4).toEqual(new Array(1,'2',3)); expect(a4).toEqual(new Array<any>(1,'2',3));
let a5 = Array(1,2,3); let a5 = Array(1,2,3);
expect(a5).toEqual(Array(1,2,3)); expect(a5).toEqual(Array(1,2,3));
let a6 = Array(1,'2','3') let a6 = Array<any>(1,'2','3')
expect(a6).toEqual(Array(1,'2','3')); expect(a6).toEqual(Array<any>(1,'2','3'));
// #endif // #endif
}) })
......
...@@ -6,7 +6,7 @@ export function testError(): Result { ...@@ -6,7 +6,7 @@ export function testError(): Result {
try { try {
throw new Error('Whoops!') throw new Error('Whoops!')
} catch (e) { } catch (e) {
expect(e.message).toEqual("Whoops!"); expect((e as Error).message).toEqual("Whoops!");
} }
}) })
// test('name', () => { // test('name', () => {
......
...@@ -113,7 +113,7 @@ export function testMath(): Result { ...@@ -113,7 +113,7 @@ export function testMath(): Result {
test('clz32', () => { test('clz32', () => {
expect(Math.clz32(1)).toEqual(31); expect(Math.clz32(1)).toEqual(31);
expect(Math.clz32(1000)).toEqual(22); expect(Math.clz32(1000)).toEqual(22);
expect(Math.clz32()).toEqual(32); expect(Math.clz32(0)).toEqual(32);
expect(Math.clz32(3.5)).toEqual(30); expect(Math.clz32(3.5)).toEqual(30);
}) })
test('cos', () => { test('cos', () => {
......
...@@ -125,7 +125,7 @@ export function testOperators(): Result { ...@@ -125,7 +125,7 @@ export function testOperators(): Result {
}) })
test('/=', () => { test('/=', () => {
let a:Number = 3; let a:number = 3;
a /= 2; a /= 2;
expect(a).toEqual(1.5); expect(a).toEqual(1.5);
}) })
......
...@@ -3,7 +3,7 @@ import { describe, test, expect, Result } from './tests.uts' ...@@ -3,7 +3,7 @@ import { describe, test, expect, Result } from './tests.uts'
export function testSet(): Result { export function testSet(): Result {
return describe("Set", () => { return describe("Set", () => {
test('size', () => { test('size', () => {
const set1 = new Set<Any>(); const set1 = new Set<any>();
const object1 = {}; const object1 = {};
set1.add(42); set1.add(42);
set1.add('forty two'); set1.add('forty two');
......
...@@ -24,7 +24,7 @@ export function test(name: string, fn: () => void) { ...@@ -24,7 +24,7 @@ export function test(name: string, fn: () => void) {
result.passed.push(name) result.passed.push(name)
// console.log('push....',result.passed.length) // console.log('push....',result.passed.length)
} catch (e) { } catch (e) {
result.failed.push(`${name}:\n${e.message}`) result.failed.push(`${name}:\n${(e as Error).message}`)
} }
result.total++ result.total++
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册