Files
swift-mirror/validation-test/Evolution/test_class_resilient_superclass_methods.swift
Slava Pestov 6798eea160 Evolution: Some of these tests pass with swift_test_mode_optimize_none_with_implicit_dynamic
The remaining failures still warrant investigation.
2019-06-11 00:54:32 -07:00

86 lines
2.4 KiB
Swift

// RUN: %target-resilience-test
// REQUIRES: executable_test
import StdlibUnittest
import class_resilient_superclass_methods
var SuperclassMethodsTest = TestSuite("SuperclassMethods")
SuperclassMethodsTest.test("AddInterposingMethod") {
do {
class Leaf : AddInterposingMethod {
override func method() -> String {
return super.method()
}
override class func classMethod() -> String {
return super.classMethod()
}
func newMethod() -> String {
return "still works"
}
}
if getVersion() == 0 {
expectEqual(Leaf().method(), "Base.method()")
expectEqual(Leaf.classMethod(), "Base.classMethod()")
} else {
expectEqual(Leaf().method(), "AddInterposingMethod.method()")
expectEqual(Leaf.classMethod(), "AddInterposingMethod.classMethod()")
}
expectEqual(Leaf().newMethod(), "still works")
}
}
SuperclassMethodsTest.test("RemoveInterposingMethod") {
do {
class Leaf : RemoveInterposingMethod {
override func method() -> String {
return super.method()
}
override class func classMethod() -> String {
return super.classMethod()
}
func newMethod() -> String {
return "still works"
}
}
if getVersion() == 0 {
expectEqual(Leaf().method(), "RemoveInterposingMethod.method()")
expectEqual(Leaf.classMethod(), "RemoveInterposingMethod.classMethod()")
} else {
expectEqual(Leaf().method(), "Base.method()")
expectEqual(Leaf.classMethod(), "Base.classMethod()")
}
expectEqual(Leaf().newMethod(), "still works")
}
}
SuperclassMethodsTest.test("InsertSuperclass") {
do {
class Leaf : InsertSuperclass {
override func method() -> String {
return super.method()
}
override class func classMethod() -> String {
return super.classMethod()
}
func newMethod() -> String {
return "still works"
}
}
if getVersion() == 0 {
expectEqual(Leaf().method(), "Base.method()")
expectEqual(Leaf().nonOverriddenMethod(), "Base.nonOverriddenMethod()")
expectEqual(Leaf.classMethod(), "Base.classMethod()")
} else {
expectEqual(Leaf().method(), "InBetween.method()")
expectEqual(Leaf().nonOverriddenMethod(), "Base.nonOverriddenMethod()")
expectEqual(Leaf.classMethod(), "InBetween.classMethod()")
}
expectEqual(Leaf().newMethod(), "still works")
}
}
runAllTests()