mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This change adds support for WASI in stdlib tests. Some tests that expect a crash to happen had to be disabled, since there's currently no way to observe such crash from a WASI host.
36 lines
937 B
Swift
36 lines
937 B
Swift
// RUN: %target-run-simple-swift
|
|
// REQUIRES: executable_test
|
|
|
|
import StdlibUnittest
|
|
|
|
let RepeatTests = TestSuite("Repeated")
|
|
RepeatTests.test("repeatElement") {
|
|
let sequence = repeatElement(1, count: 5)
|
|
expectEqual(sequence.count, 5)
|
|
expectEqualSequence(sequence, [1, 1, 1, 1, 1])
|
|
expectEqual(sequence.startIndex, 0)
|
|
expectEqual(sequence.endIndex, 5)
|
|
expectEqual(sequence[0], 1)
|
|
}
|
|
|
|
RepeatTests.test("associated-types") {
|
|
typealias Subject = Repeated<String>
|
|
expectRandomAccessCollectionAssociatedTypes(
|
|
collectionType: Subject.self,
|
|
iteratorType: IndexingIterator<Subject>.self,
|
|
subSequenceType: Slice<Subject>.self,
|
|
indexType: Int.self,
|
|
indicesType: CountableRange<Int>.self)
|
|
}
|
|
|
|
#if !os(WASI)
|
|
// Trap tests aren't available on WASI.
|
|
RepeatTests.test("out-of-bounds") {
|
|
let sequence = repeatElement(0, count: 1)
|
|
expectCrashLater()
|
|
_ = sequence[sequence.count]
|
|
}
|
|
#endif
|
|
|
|
runAllTests()
|