Skip to content

[pull] swiftwasm from main #3859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/stdlib/KVOKeyPaths.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,6 @@ testObjectForOptionalKeyPath.optionalObject = nil
testObjectForOptionalKeyPath.optionalObject = "foo"

// CHECK-51-LABEL: observe keyPath with optional value
// CHECK-51-NEXT: oldValue = Optional(nil), newValue = {{Optional\(nil\)|nil}}
// CHECK-51-NEXT: oldValue = Optional(nil), newValue = {{Optional\(nil\)|nil}}
// CHECK-51-NEXT: oldValue = Optional(nil), newValue = Optional(Optional("foo"))
// CHECK-51-NEXT: oldValue = {{Optional\(nil\)|nil}}, newValue = {{Optional\(nil\)|nil}}
// CHECK-51-NEXT: oldValue = {{Optional\(nil\)|nil}}, newValue = {{Optional\(nil\)|nil}}
// CHECK-51-NEXT: oldValue = {{Optional\(nil\)|nil}}, newValue = Optional(Optional("foo"))
26 changes: 22 additions & 4 deletions validation-test/stdlib/ArrayTrapsObjC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ ArrayTraps.test("bounds_with_downcast")
_ = da[2]
}

func hasBackdeployedConcurrencyRuntime() -> Bool {
// If the stdlib we've loaded predates Swift 5.5, then we're running on a back
// deployed concurrency runtime, which has the side effect of disabling
// regular runtime exclusivity checks.
//
// This makes the two tests below fall back to older, higher-level exclusivity
// checks in the stdlib, which will still trap, but with a different message.
if #available(SwiftStdlib 5.5, *) { return false } // recent enough production stdlib
if #available(SwiftStdlib 9999, *) { return false } // dev stdlib
return true
}

var ArraySemanticOptzns = TestSuite("ArraySemanticOptzns" + testSuiteSuffix)

class BaseClass {
Expand Down Expand Up @@ -131,8 +143,11 @@ ArraySemanticOptzns.test("inout_rule_violated_isNativeBuffer")
.skip(.custom(
{ _isFastAssertConfiguration() },
reason: "this trap is not guaranteed to happen in -Ounchecked"))
.crashOutputMatches(_isDebugAssertConfiguration() ?
"Fatal access conflict detected." : "")
.crashOutputMatches(
!_isDebugAssertConfiguration() ? ""
: hasBackdeployedConcurrencyRuntime() ? "inout rules were violated"
: "Fatal access conflict detected."
)
.code {
let v = ViolateInoutSafetySwitchToObjcBuffer()
expectCrashLater()
Expand Down Expand Up @@ -174,8 +189,11 @@ ArraySemanticOptzns.test("inout_rule_violated_needsElementTypeCheck")
.skip(.custom(
{ _isFastAssertConfiguration() },
reason: "this trap is not guaranteed to happen in -Ounchecked"))
.crashOutputMatches(_isDebugAssertConfiguration() ?
"Fatal access conflict detected." : "")
.crashOutputMatches(
!_isDebugAssertConfiguration() ? ""
: hasBackdeployedConcurrencyRuntime() ? "inout rules were violated"
: "Fatal access conflict detected."
)
.code {
let v = ViolateInoutSafetyNeedElementTypeCheck()
expectCrashLater()
Expand Down
60 changes: 0 additions & 60 deletions validation-test/stdlib/SetOperations.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -248,66 +248,6 @@ suite.test("symmetricDifference.${inputKind}.${argumentKind}") {
% end
% end

% for inputKind, inputGenerator in inputKinds.items():
% for argumentKind, argumentGenerator in argumentKinds.items():
% needsCocoa = inputKind == "cocoa" or argumentKind == "cocoa"
% if needsCocoa:
#if _runtime(_ObjC)
% end
suite.test("formIntersection.${inputKind}.${argumentKind}") {
var a = ${inputGenerator}(0 ..< 10, identity: 1)
let b = ${argumentGenerator}(5 ..< 15, identity: 2)
a.formSymmetricDifference(b)
expectTrue(isNativeSet(a))
expectEqual(a.count, 10)
// Check the resulting items and that they come from the correct input set.
for v in 5 ..< 10 {
expectFalse(a.contains(Value(v)), "Found \(v) in result")
}
for v in Array(0 ..< 5) + Array(10 ..< 15) {
guard let i = a.firstIndex(of: Value(v)) else {
expectTrue(false, "Could not find \(v) in result")
continue
}
expectEqual(a[i].identity, v < 5 ? 1 : 2)
}
}
% if needsCocoa:
#endif
% end
% end
% end

% for inputKind, inputGenerator in inputKinds.items():
% for argumentKind, argumentGenerator in argumentKinds.items():
% needsCocoa = inputKind == "cocoa" or argumentKind == "cocoa"
% if needsCocoa:
#if _runtime(_ObjC)
% end
suite.test("symmetricDifference.${inputKind}.${argumentKind}") {
let a = ${inputGenerator}(0 ..< 10, identity: 1)
let b = ${argumentGenerator}(5 ..< 15, identity: 2)
let c = a.symmetricDifference(b)
expectTrue(isNativeSet(c))
expectEqual(c.count, 10)
// Check the resulting items and that they come from the correct input set.
for v in 5 ..< 10 {
expectFalse(c.contains(Value(v)), "Found \(v) in result")
}
for v in Array(0 ..< 5) + Array(10 ..< 15) {
guard let i = c.firstIndex(of: Value(v)) else {
expectTrue(false, "Could not find \(v) in result")
continue
}
expectEqual(c[i].identity, v < 5 ? 1 : 2)
}
}
% if needsCocoa:
#endif
% end
% end
% end

% for inputKind, inputGenerator in inputKinds.items():
% for argumentKind, argumentGenerator in argumentKinds.items():
% needsCocoa = inputKind == "cocoa" or argumentKind == "cocoa"
Expand Down