提交 b6d2f282 编写于 作者: 杜庆泉's avatar 杜庆泉

修改可迭代协议 测试示例

上级 febddb95
......@@ -240,6 +240,14 @@ export function testNumber() : Result {
expect((JSON.stringify(0.0000001))).toEqual("1e-7");
expect((JSON.stringify(100000000000000000000.0))).toEqual("100000000000000000000");
expect((JSON.stringify(1000000000000000000000.0))).toEqual("1e+21");
let a11:number|null = null
let b11:Int|null = null
expect(a11.toString()).toEqual("null");
expect(b11.toString()).toEqual("null");
// #endif
})
......
......@@ -6,18 +6,22 @@ class TestSuper implements UTSKeyIterable {
r2: Int = 1
r3: boolean = false
ignoredKeys(): string[] {
override ignoredKeys(): string[] {
return ["r1"]
}
}
class TestChild extends TestSuper implements UTSValueIterable {
class TestChild extends TestSuper implements UTSValueIterable<any | null> {
a: string = ""
b: Int = 1
c: boolean = false
holderArray: (any | null)[] = [11, 22, null, 33, 44, null];
constructor(){
super()
}
override ignoredKeys(): string[] {
......@@ -26,11 +30,11 @@ class TestChild extends TestSuper implements UTSValueIterable {
return result
}
valueIterator(): UTSIterator<any | null> {
override valueIterator(): UTSIterator<any | null> {
let holderIndex = 0;
let obj: UTSIterator<any | null> = {
next(): UTSIteratorResult<any | null> {
return UTSIteratorResult<any | null>(holderIndex == this.holderArray.count - 1, this.holderArray[holderIndex++])
return UTSIteratorResult<any | null>(holderIndex == this.holderArray.size - 1, this.holderArray[holderIndex++])
}
}
return obj
......@@ -63,7 +67,8 @@ export function testIterator(): Result {
dic.set("a", 1)
dic.set("b", 2)
dic.set("c", 3)
let result2: [any] = []
//let result2: [any] = []
let result2: Array<any> = []
for (let item of dic) {
result2.add(item)
}
......@@ -74,7 +79,7 @@ export function testIterator(): Result {
// #endif
// test Set
let set = new Set()
let set = new Set<any>()
set.add("a")
set.add("b")
set.add("c")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册