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

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

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