func testBaseClassLogging()

in PlaygroundLogger/PlaygroundLoggerTests/LegacyPlaygroundLoggerTests.swift [505:537]


    func testBaseClassLogging() {
        class Parent { var a = 1; var b = 2 }
        class Child : Parent { var c = 3 }
        let object = Child()
        let logdata = legacyLog(instance: object, name: "object", id: 0, startLine: 0, endLine: 0, startColumn: 0, endColumn: 0) as! NSData
        guard let decoded = legacyLogDecode(logdata) else {
            XCTFail("Failed to decode log data")
            return
        }
        guard let structured = decoded.object as? PlaygroundDecodedObject_Structured else {
            XCTFail("Decoded object is not structured")
            return
        }
        var seen_parent = false
        var seen_a = false
        var seen_b = false
        var seen_c = false
        for child in structured.children {
            if let structured_child = child as? PlaygroundDecodedObject_Structured {
                if structured_child.name == "super" {
                    seen_parent = true
                    for parent_child in structured_child.children {
                        if parent_child.name == "a" { seen_a = true }
                        if parent_child.name == "b" { seen_b = true }
                    }
                }
            }
            if child.name == "c" {
                seen_c = true
            }
        }
        XCTAssert(seen_parent && seen_a && seen_b && seen_c)
    }