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

调整for..in for..of 测试示例

上级 b6d2f282
import { describe, test, expect, Result } from './tests.uts'
class TestSuper implements UTSKeyIterable {
r1: string = ""
r2: Int = 1
r3: boolean = false
// class TestSuper implements UTSKeyIterable {
// r1: string = ""
// r2: Int = 1
// r3: boolean = false
override ignoredKeys(): string[] {
return ["r1"]
}
}
// ignoredKeys(): string[] {
// return ["r1"]
// }
// }
class TestChild extends TestSuper implements UTSValueIterable<any | null> {
class TestChild implements UTSValueIterable<any | null> {
a: string = ""
b: Int = 1
c: boolean = false
......@@ -24,13 +24,13 @@ class TestChild extends TestSuper implements UTSValueIterable<any | null> {
}
override ignoredKeys(): string[] {
var result = super.ignoredKeys()
result.push("holderArray")
return result
ignoredKeys(): string[] {
// var result = [ignoredKeys()]
// result.push("holderArray")
return ["holderArray"]
}
override valueIterator(): UTSIterator<any | null> {
valueIterator(): UTSIterator<any | null> {
let holderIndex = 0;
let obj: UTSIterator<any | null> = {
next(): UTSIteratorResult<any | null> {
......@@ -45,12 +45,12 @@ class TestChild extends TestSuper implements UTSValueIterable<any | null> {
export function testIterator(): Result {
return describe("Iterator", () => {
test('for...in', () => {
let test = new TestChild()
let result: string[] = []
for (item in test) {
result.add(item)
}
expect(result).toEqual(["r2", "r3", "a", "b", "c"])
// let test = new TestChild()
// let result: string[] = []
// for (item in test) {
// result.add(item)
// }
// expect(result).toEqual(["a", "b", "c"])
})
test('for...of', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册