# How to use func class

Best Mockingbird code snippet using func

Transforms.swift

Source:Transforms.swift

`...43}44public extension Rotation {45 static let identity = Rotation()46 /// Define a rotation around the X axis47 static func pitch(_ radians: Double) -> Rotation {48 let c = cos(radians)49 let s = sin(radians)50 return self.init(51 1, 0, 0,52 0, c, -s,53 0, s, c54 )55 }56 /// Define a rotation around the Y axis57 static func yaw(_ radians: Double) -> Rotation {58 let c = cos(radians)59 let s = sin(radians)60 return self.init(61 c, 0, s,62 0, 1, 0,63 -s, 0, c64 )65 }66 /// Define a rotation around the Z axis67 static func roll(_ radians: Double) -> Rotation {68 let c = cos(radians)69 let s = sin(radians)70 return self.init(71 c, -s, 0,72 s, c, 0,73 0, 0, 174 )75 }76 /// Define a rotation using 3x3 matrix coefficients77 init(_ m11: Double, _ m12: Double, _ m13: Double,78 _ m21: Double, _ m22: Double, _ m23: Double,79 _ m31: Double, _ m32: Double, _ m33: Double) {80 assert(!m11.isNaN)81 self.m11 = m1182 self.m12 = m1283 self.m13 = m1384 self.m21 = m2185 self.m22 = m2286 self.m23 = m2387 self.m31 = m3188 self.m32 = m3289 self.m33 = m3390 }91 /// Creates an identity Rotation92 init() {93 self.init(1, 0, 0, 0, 1, 0, 0, 0, 1)94 }95 /// Define a rotation from an axis vector and an angle96 init?(axis: Vector, radians: Double) {97 let length = axis.length98 guard length.isFinite, length > epsilon else {99 return nil100 }101 self.init(unchecked: axis / length, radians: radians)102 }103 /// Define a rotation from Euler angles104 // http://planning.cs.uiuc.edu/node102.html105 init(pitch: Double, yaw: Double = 0, roll: Double = 0) {106 self = .pitch(pitch)107 if yaw != 0 {108 self *= .yaw(yaw)109 }110 if roll != 0 {111 self *= .roll(roll)112 }113 }114 init(yaw: Double, pitch: Double = 0, roll: Double = 0) {115 self = .yaw(yaw)116 if pitch != 0 {117 self *= .pitch(pitch)118 }119 if roll != 0 {120 self *= .roll(roll)121 }122 }123 init(roll: Double, yaw: Double = 0, pitch: Double = 0) {124 self = .roll(roll)125 if yaw != 0 {126 self *= .yaw(yaw)127 }128 if pitch != 0 {129 self *= .pitch(pitch)130 }131 }132 // http://planning.cs.uiuc.edu/node103.html133 var pitch: Double {134 return atan2(m32, m33)135 }136 var yaw: Double {137 return atan2(-m31, sqrt(m32 * m32 + m33 * m33))138 }139 var roll: Double {140 return atan2(m21, m11)141 }142 static prefix func - (rhs: Rotation) -> Rotation {143 // transpose matrix144 return Rotation(145 rhs.m11,146 rhs.m21,147 rhs.m31,148 rhs.m12,149 rhs.m22,150 rhs.m32,151 rhs.m13,152 rhs.m23,153 rhs.m33154 )155 }156 static func * (lhs: Rotation, rhs: Rotation) -> Rotation {157 return Rotation(158 lhs.m11 * rhs.m11 + lhs.m21 * rhs.m12 + lhs.m31 * rhs.m13,159 lhs.m12 * rhs.m11 + lhs.m22 * rhs.m12 + lhs.m32 * rhs.m13,160 lhs.m13 * rhs.m11 + lhs.m23 * rhs.m12 + lhs.m33 * rhs.m13,161 lhs.m11 * rhs.m21 + lhs.m21 * rhs.m22 + lhs.m31 * rhs.m23,162 lhs.m12 * rhs.m21 + lhs.m22 * rhs.m22 + lhs.m32 * rhs.m23,163 lhs.m13 * rhs.m21 + lhs.m23 * rhs.m22 + lhs.m33 * rhs.m23,164 lhs.m11 * rhs.m31 + lhs.m21 * rhs.m32 + lhs.m31 * rhs.m33,165 lhs.m12 * rhs.m31 + lhs.m22 * rhs.m32 + lhs.m32 * rhs.m33,166 lhs.m13 * rhs.m31 + lhs.m23 * rhs.m32 + lhs.m33 * rhs.m33167 )168 }169 static func *= (lhs: inout Rotation, rhs: Rotation) {170 lhs = lhs * rhs171 }172}173internal extension Rotation {174 // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/175 init(unchecked axis: Vector, radians: Double) {176 assert(axis.isNormalized)177 let c = cos(radians)178 let s = sin(radians)179 let t = 1 - c180 let x = axis.x181 let y = axis.y182 let z = axis.z183 self.init(184 t * x * x + c, t * x * y - z * s, t * x * z + y * s,185 t * x * y + z * s, t * y * y + c, t * y * z - x * s,186 t * x * z - y * s, t * y * z + x * s, t * z * z + c187 )188 }189}190public struct Transform: Hashable {191 public var offset: Vector192 public var rotation: Rotation193 public var scale: Vector194 public init(195 offset: Vector = .zero,196 rotation: Rotation = .identity,197 scale: Vector = .init(1, 1, 1)198 ) {199 self.offset = offset200 self.rotation = rotation201 self.scale = scale202 }203}204public extension Transform {205 static let identity = Transform()206 var isFlipped: Bool {207 var flipped = scale.x < 0208 if scale.y < 0 { flipped = !flipped }209 if scale.z < 0 { flipped = !flipped }210 return flipped211 }212 mutating func translate(by v: Vector) {213 offset = offset + v.scaled(by: scale).rotated(by: rotation)214 }215 mutating func rotate(by r: Rotation) {216 rotation *= r217 }218 mutating func scale(by v: Vector) {219 scale = scale.scaled(by: v)220 }221 static func * (lhs: Transform, rhs: Transform) -> Transform {222 var result = rhs223 result.translate(by: lhs.offset)224 result.scale(by: lhs.scale)225 result.rotation *= lhs.rotation226 return result227 }228}229public extension Mesh {230 func translated(by v: Vector) -> Mesh {231 return Mesh(polygons.map { \$0.translated(by: v) })232 }233 func rotated(by m: Rotation) -> Mesh {234 return Mesh(polygons.map { \$0.rotated(by: m) })235 }236 func scaled(by v: Vector) -> Mesh {237 if v.x == v.y, v.y == v.z {238 // optimization - avoids scaling normals239 return scaled(by: v.x)240 }241 return Mesh(polygons.map { \$0.scaled(by: v) })242 }243 func scaled(by f: Double) -> Mesh {244 return Mesh(polygons.map { \$0.scaled(by: f) })245 }246 func scaleCorrected(for v: Vector) -> Mesh {247 return Mesh(polygons.map { \$0.scaleCorrected(for: v) })248 }249 func transformed(by t: Transform) -> Mesh {250 return Mesh(polygons.map { \$0.transformed(by: t) })251 }252}253public extension Polygon {254 func translated(by v: Vector) -> Polygon {255 return Polygon(256 unchecked: vertices.map { \$0.translated(by: v) },257 normal: plane.normal,258 isConvex: isConvex,259 bounds: bounds.translated(by: v),260 material: material261 )262 }263 func rotated(by m: Rotation) -> Polygon {264 return Polygon(265 unchecked: vertices.map { \$0.rotated(by: m) },266 normal: plane.normal.rotated(by: m),267 isConvex: isConvex,268 material: material269 )270 }271 func scaled(by v: Vector) -> Polygon {272 var v = v273 let limit = 0.001274 v.x = v.x < 0 ? min(v.x, -limit) : max(v.x, limit)275 v.y = v.y < 0 ? min(v.y, -limit) : max(v.y, limit)276 v.z = v.z < 0 ? min(v.z, -limit) : max(v.z, limit)277 var flipped = v.x < 0278 if v.y < 0 { flipped = !flipped }279 if v.z < 0 { flipped = !flipped }280 let vertices = self.vertices.map { \$0.scaled(by: v) }281 let vn = Vector(1 / v.x, 1 / v.y, 1 / v.z)282 return Polygon(283 unchecked: flipped ? vertices.reversed() : vertices,284 normal: plane.normal.scaled(by: vn).normalized(),285 isConvex: isConvex,286 bounds: bounds.scaled(by: v),287 material: material288 )289 }290 func scaled(by f: Double) -> Polygon {291 let limit = 0.001292 let f = f < 0 ? min(f, -limit) : max(f, limit)293 let polygon = Polygon(294 unchecked: vertices.map { \$0.scaled(by: f) },295 normal: plane.normal,296 isConvex: isConvex,297 bounds: bounds.scaled(by: f),298 material: material299 )300 return f < 0 ? polygon.inverted() : polygon301 }302 func transformed(by t: Transform) -> Polygon {303 return scaled(by: t.scale).rotated(by: t.rotation).translated(by: t.offset)304 }305 func scaleCorrected(for v: Vector) -> Polygon {306 var flipped = v.x < 0307 if v.y < 0 { flipped = !flipped }308 if v.z < 0 { flipped = !flipped }309 return Polygon(310 unchecked: flipped ? vertices.reversed() : vertices,311 normal: plane.normal,312 isConvex: isConvex,313 bounds: bounds,314 material: material315 )316 }317}318public extension Vertex {319 func translated(by v: Vector) -> Vertex {320 return Vertex(position + v, normal, texcoord)321 }322 func rotated(by m: Rotation) -> Vertex {323 return Vertex(position.rotated(by: m), normal.rotated(by: m), texcoord)324 }325 func scaled(by v: Vector) -> Vertex {326 let vn = Vector(1 / v.x, 1 / v.y, 1 / v.z)327 return Vertex(position.scaled(by: v), normal.scaled(by: vn).normalized(), texcoord)328 }329 func scaled(by f: Double) -> Vertex {330 return Vertex(position * f, normal, texcoord)331 }332 func transformed(by t: Transform) -> Vertex {333 return scaled(by: t.scale).rotated(by: t.rotation).translated(by: t.offset)334 }335}336public extension Vector {337 /// NOTE: no need for a translated() function because of the + operator338 func rotated(by m: Rotation) -> Vector {339 return Vector(340 x * m.m11 + y * m.m21 + z * m.m31,341 x * m.m12 + y * m.m22 + z * m.m32,342 x * m.m13 + y * m.m23 + z * m.m33343 )344 }345 func scaled(by v: Vector) -> Vector {346 return Vector(x * v.x, y * v.y, z * v.z)347 }348 func transformed(by t: Transform) -> Vector {349 return scaled(by: t.scale).rotated(by: t.rotation) + t.offset350 }351}352public extension PathPoint {353 func translated(by v: Vector) -> PathPoint {354 return PathPoint(position + v, isCurved: isCurved)355 }356 func rotated(by r: Rotation) -> PathPoint {357 return PathPoint(position.rotated(by: r), isCurved: isCurved)358 }359 func scaled(by v: Vector) -> PathPoint {360 return PathPoint(position.scaled(by: v), isCurved: isCurved)361 }362 func scaled(by f: Double) -> PathPoint {363 return PathPoint(position * f, isCurved: isCurved)364 }365 func transformed(by t: Transform) -> PathPoint {366 return PathPoint(position.transformed(by: t), isCurved: isCurved)367 }368}369public extension Path {370 func translated(by v: Vector) -> Path {371 return Path(372 unchecked: points.map { \$0.translated(by: v) },373 plane: plane?.translated(by: v), subpathIndices: subpathIndices)374 }375 func rotated(by r: Rotation) -> Path {376 return Path(377 unchecked: points.map { \$0.rotated(by: r) },378 plane: plane?.rotated(by: r), subpathIndices: subpathIndices)379 }380 func scaled(by v: Vector) -> Path {381 return Path(382 unchecked: points.map { \$0.scaled(by: v) },383 plane: plane?.scaled(by: v), subpathIndices: subpathIndices384 )385 }386 func scaled(by f: Double) -> Path {387 return Path(388 unchecked: points.map { \$0.scaled(by: f) },389 plane: plane?.scaled(by: f), subpathIndices: subpathIndices390 )391 }392 func transformed(by t: Transform) -> Path {393 // TODO: manually transform plane so we can make this more efficient394 return Path(395 unchecked: points.map { \$0.transformed(by: t) },396 plane: plane?.transformed(by: t), subpathIndices: subpathIndices397 )398 }399}400public extension Plane {401 func translated(by v: Vector) -> Plane {402 return Plane(unchecked: normal, pointOnPlane: normal * w + v)403 }404 func rotated(by r: Rotation) -> Plane {405 return Plane(unchecked: normal.rotated(by: r), w: w)406 }407 func scaled(by v: Vector) -> Plane {408 let vn = Vector(1 / v.x, 1 / v.y, 1 / v.z)409 let p = (normal * w).scaled(by: v)410 return Plane(unchecked: normal.scaled(by: vn).normalized(), pointOnPlane: p)411 }412 func scaled(by f: Double) -> Plane {413 return Plane(unchecked: normal, w: w * f)414 }415 func transformed(by t: Transform) -> Plane {416 return scaled(by: t.scale).rotated(by: t.rotation).translated(by: t.offset)417 }418}419public extension Bounds {420 func translated(by v: Vector) -> Bounds {421 return Bounds(min: min + v, max: max + v)422 }423 func rotated(by r: Rotation) -> Bounds {424 return Bounds(points: corners.map { \$0.rotated(by: r) })425 }426 func scaled(by v: Vector) -> Bounds {427 return Bounds(min: min.scaled(by: v), max: max.scaled(by: v))428 }429 func scaled(by f: Double) -> Bounds {430 return Bounds(min: min * f, max: max * f)431 }432 func transformed(by t: Transform) -> Bounds {433 return Bounds(points: corners.map { \$0.transformed(by: t) })434 }435}...`

Observable+BlockingTest.swift

Source:Observable+BlockingTest.swift

`...11class ObservableBlockingTest : RxTest {12}13// toArray14extension ObservableBlockingTest {15 func testToArray_empty() {16 XCTAssertEqual(try Observable<Int>.empty().toBlocking().toArray(), [])17 }18 19 func testToArray_return() {20 XCTAssertEqual(try Observable.just(42).toBlocking().toArray(), [42])21 }22 23 func testToArray_fail() {24 XCTAssertThrowsErrorEqual(try Observable<Int>.error(testError).toBlocking().toArray(), testError)25 }26 27 func testToArray_someData() {28 XCTAssertEqual(try Observable.of(42, 43, 44, 45).toBlocking().toArray(), [42, 43, 44, 45])29 }30 31 func testToArray_withRealScheduler() {32 let scheduler = ConcurrentDispatchQueueScheduler(qos: .default)33 34 let array = try! Observable<Int64>.interval(0.001, scheduler: scheduler)35 .take(10)36 .toBlocking()37 .toArray()38 39 XCTAssertEqual(array, Array(0..<10))40 }41 func testToArray_independent() {42 for i in 0 ..< 10 {43 let scheduler = ConcurrentDispatchQueueScheduler(qos: .default)44 func operation1()->Observable<Int>{45 return Observable.of(1, 2).subscribeOn(scheduler)46 }47 let a = try! operation1().toBlocking().toArray()48 let b = try! operation1().toBlocking().toArray()49 let c = try! operation1().toBlocking().toArray()50 let d = try! operation1().toBlocking().toArray()51 XCTAssertEqual(a, [1, 2])52 XCTAssertEqual(b, [1, 2])53 XCTAssertEqual(c, [1, 2])54 XCTAssertEqual(d, [1, 2])55 }56 }57 func testToArray_timeout() {58 XCTAssertThrowsError(try Observable<Int>.never().toBlocking(timeout: 0.01).toArray()) { error in59 XCTAssertErrorEqual(error, RxError.timeout)60 }61 }62}63// first64extension ObservableBlockingTest {65 func testFirst_empty() {66 XCTAssertNil(try Observable<Int>.empty().toBlocking().first())67 }68 69 func testFirst_return() {70 XCTAssertEqual(try Observable.just(42).toBlocking().first(), 42)71 }72 73 func testFirst_fail() {74 XCTAssertThrowsErrorEqual(try Observable<Int>.error(testError).toBlocking().first(), testError)75 }76 77 func testFirst_someData() {78 XCTAssertEqual(try Observable.of(42, 43, 44, 45).toBlocking().first(), 42)79 }80 81 func testFirst_withRealScheduler() {82 let scheduler = ConcurrentDispatchQueueScheduler(qos: .default)83 84 let element = try! Observable<Int64>.interval(0.001, scheduler: scheduler)85 .take(10)86 .toBlocking()87 .first()88 89 XCTAssertEqual(element, 0)90 }91 func testFirst_independent() {92 for i in 0 ..< 10 {93 let scheduler = ConcurrentDispatchQueueScheduler(qos: .default)94 func operation1()->Observable<Int>{95 return Observable.just(1).subscribeOn(scheduler)96 }97 let a = try! operation1().toBlocking().first()98 let b = try! operation1().toBlocking().first()99 let c = try! operation1().toBlocking().first()100 let d = try! operation1().toBlocking().first()101 XCTAssertEqual(a, 1)102 XCTAssertEqual(b, 1)103 XCTAssertEqual(c, 1)104 XCTAssertEqual(d, 1)105 }106 }107 func testFirst_timeout() {108 XCTAssertThrowsError(try Observable<Int>.never().toBlocking(timeout: 0.01).first()) { error in109 XCTAssertErrorEqual(error, RxError.timeout)110 }111 }112}113// last114extension ObservableBlockingTest {115 func testLast_empty() {116 XCTAssertNil(try Observable<Int>.empty().toBlocking().last())117 }118 119 func testLast_return() {120 XCTAssertEqual(try Observable.just(42).toBlocking().last(), 42)121 }122 123 func testLast_fail() {124 XCTAssertThrowsErrorEqual(try Observable<Int>.error(testError).toBlocking().last(), testError)125 }126 127 func testLast_someData() {128 XCTAssertEqual(try Observable.of(42, 43, 44, 45).toBlocking().last(), 45)129 }130 131 func testLast_withRealScheduler() {132 let scheduler = ConcurrentDispatchQueueScheduler(qos: .default)133 134 let element = try! Observable<Int64>.interval(0.001, scheduler: scheduler)135 .take(10)136 .toBlocking()137 .last()138 139 XCTAssertEqual(element, 9)140 }141 func testLast_independent() {142 for i in 0 ..< 10 {143 let scheduler = ConcurrentDispatchQueueScheduler(qos: .background)144 func operation1()->Observable<Int>{145 return Observable.just(1).subscribeOn(scheduler)146 }147 let a = try! operation1().toBlocking().last()148 let b = try! operation1().toBlocking().last()149 let c = try! operation1().toBlocking().last()150 let d = try! operation1().toBlocking().last()151 XCTAssertEqual(a, 1)152 XCTAssertEqual(b, 1)153 XCTAssertEqual(c, 1)154 XCTAssertEqual(d, 1)155 }156 }157 func testLast_timeout() {158 XCTAssertThrowsError(try Observable<Int>.never().toBlocking(timeout: 0.01).last()) { error in159 XCTAssertErrorEqual(error, RxError.timeout)160 }161 }162}163// single164extension ObservableBlockingTest {165 func testSingle_empty() {166 XCTAssertThrowsErrorEqual(try Observable<Int>.empty().toBlocking().single(), RxError.noElements)167 }168 169 func testSingle_return() {170 XCTAssertEqual(try Observable.just(42).toBlocking().single(), 42)171 }172 func testSingle_two() {173 XCTAssertThrowsErrorEqual(try Observable.of(42, 43).toBlocking().single(), RxError.moreThanOneElement)174 }175 func testSingle_someData() {176 XCTAssertThrowsErrorEqual(try Observable.of(42, 43, 44, 45).toBlocking().single(), RxError.moreThanOneElement)177 }178 179 func testSingle_fail() {180 XCTAssertThrowsErrorEqual(try Observable<Int>.error(testError).toBlocking().single(), testError)181 }182 183 func testSingle_withRealScheduler() {184 let scheduler = ConcurrentDispatchQueueScheduler(qos: .default)185 186 let element = try! Observable<Int64>.interval(0.001, scheduler: scheduler)187 .take(1)188 .toBlocking()189 .single()190 191 XCTAssertEqual(element, 0)192 }193 194 func testSingle_predicate_empty() {195 XCTAssertThrowsErrorEqual(try Observable<Int>.empty().toBlocking().single { _ in true }, RxError.noElements)196 }197 198 func testSingle_predicate_return() {199 XCTAssertEqual(try Observable.just(42).toBlocking().single( { _ in true } ), 42)200 }201 202 func testSingle_predicate_someData_one_match() {203 var predicateVals = [Int]()204 do {205 let element = try Observable.of(42, 43, 44, 45).toBlocking().single( { e in206 predicateVals.append(e)207 return e == 44208 } )209 XCTAssertEqual(element, 44)210 }211 catch _ {212 XCTFail()213 }214 XCTAssertEqual(predicateVals, [42, 43, 44, 45])215 }216 func testSingle_predicate_someData_two_match() {217 var predicateVals = [Int]()218 do {219 _ = try Observable.of(42, 43, 44, 45).toBlocking().single( { e in220 predicateVals.append(e)221 return e >= 43222 } )223 XCTFail()224 }225 catch let e {226 XCTAssertErrorEqual(e, RxError.moreThanOneElement)227 }228 XCTAssertEqual(predicateVals, [42, 43, 44])229 }230 231 func testSingle_predicate_none() {232 var predicateVals = [Int]()233 do {234 _ = try Observable.of(42, 43, 44, 45).toBlocking().single( { e in235 predicateVals.append(e)236 return e > 50237 } )238 XCTFail()239 }240 catch let e {241 XCTAssertErrorEqual(e, RxError.noElements)242 }243 XCTAssertEqual(predicateVals, [42, 43, 44, 45])244 }245 func testSingle_predicate_throws() {246 var predicateVals = [Int]()247 do {248 _ = try Observable.of(42, 43, 44, 45, scheduler: CurrentThreadScheduler.instance).toBlocking().single( { e in249 predicateVals.append(e)250 if e < 43 { return false }251 throw testError252 } )253 XCTFail()254 }255 catch let e {256 XCTAssertErrorEqual(e, testError)257 }258 XCTAssertEqual(predicateVals, [42, 43])259 }260 261 func testSingle_predicate_fail() {262 XCTAssertThrowsErrorEqual(try Observable<Int>.error(testError).toBlocking().single { _ in true }, testError)263 }264 265 func testSingle_predicate_withRealScheduler() {266 let scheduler = ConcurrentDispatchQueueScheduler(qos: .default)267 268 let element = try! Observable<Int64>.interval(0.001, scheduler: scheduler)269 .take(4)270 .toBlocking()271 .single( { \$0 == 3 } )272 273 XCTAssertEqual(element, 3)274 }275 func testSingle_independent() {276 for i in 0 ..< 10 {277 let scheduler = ConcurrentDispatchQueueScheduler(qos: .default)278 func operation1()->Observable<Int>{279 return Observable.just(1).subscribeOn(scheduler)280 }281 let a = try! operation1().toBlocking().single()282 let b = try! operation1().toBlocking().single()283 let c = try! operation1().toBlocking().single()284 let d = try! operation1().toBlocking().single()285 XCTAssertEqual(a, 1)286 XCTAssertEqual(b, 1)287 XCTAssertEqual(c, 1)288 XCTAssertEqual(d, 1)289 }290 }291 func testSingle_timeout() {292 XCTAssertThrowsError(try Observable<Int>.never().toBlocking(timeout: 0.01).single()) { error in293 XCTAssertErrorEqual(error, RxError.timeout)294 }295 }296 func testSinglePredicate_timeout() {297 XCTAssertThrowsError(try Observable<Int>.never().toBlocking(timeout: 0.01).single { _ in true }) { error in298 XCTAssertErrorEqual(error, RxError.timeout)299 }300 }301}302// materialize303extension ObservableBlockingTest {304 func testMaterialize_empty() {305 let result = Observable<Int>.empty().toBlocking().materialize()306 307 switch result {308 case .completed(let elements):309 XCTAssertEqual(elements, [])310 case .failed:311 XCTFail("Expected result to be complete successfully, but result was failed.")312 }313 }314 315 func testMaterialize_empty_fail() {316 let result = Observable<Int>.error(testError).toBlocking().materialize()317 318 switch result {319 case .completed:320 XCTFail("Expected result to be complete with error, but result was successful.")321 case .failed(let elements, let error):322 XCTAssertEqual(elements, [])323 XCTAssertErrorEqual(error, testError)324 }325 }326 327 func testMaterialize_someData() {328 let result = Observable.of(42, 43, 44, 45).toBlocking().materialize()329 330 switch result {331 case .completed(let elements):332 XCTAssertEqual(elements, [42, 43, 44, 45])333 case .failed:334 XCTFail("Expected result to be complete successfully, but result was failed.")335 }336 }337 338 func testMaterialize_someData_fail() {339 let sequence = Observable.concat(Observable.of(42, 43, 44, 45), Observable<Int>.error(testError))340 let result = sequence.toBlocking().materialize()341 342 switch result {343 case .completed:344 XCTFail("Expected result to be complete with error, but result was successful.")345 case .failed(let elements, let error):346 XCTAssertEqual(elements, [42, 43, 44, 45])347 XCTAssertErrorEqual(error, testError)348 }349 }350}...`

Enums+Fixtures.swift

Source:Enums+Fixtures.swift

`2// swiftlint:disable file_length3import Foundation4@testable import MapboxMaps5extension Value where T == Visibility {6 static func testConstantValue() -> Value<Visibility> {7 return .constant(Visibility.testConstantValue())8 }9}10extension Visibility {11 static func testConstantValue() -> Visibility {12 return .visible13 }14}15// MARK: LINE_CAP16extension Value where T == LineCap {17 static func testConstantValue() -> Value<LineCap> {18 return .constant(LineCap.testConstantValue())19 }20}21extension LineCap {22 static func testConstantValue() -> LineCap {23 return LineCap(rawValue: "butt")!24 }25}26// MARK: LINE_JOIN27extension Value where T == LineJoin {28 static func testConstantValue() -> Value<LineJoin> {29 return .constant(LineJoin.testConstantValue())30 }31}32extension LineJoin {33 static func testConstantValue() -> LineJoin {34 return LineJoin(rawValue: "bevel")!35 }36}37// MARK: ICON_ANCHOR38extension Value where T == IconAnchor {39 static func testConstantValue() -> Value<IconAnchor> {40 return .constant(IconAnchor.testConstantValue())41 }42}43extension IconAnchor {44 static func testConstantValue() -> IconAnchor {45 return IconAnchor(rawValue: "center")!46 }47}48// MARK: ICON_PITCH_ALIGNMENT49extension Value where T == IconPitchAlignment {50 static func testConstantValue() -> Value<IconPitchAlignment> {51 return .constant(IconPitchAlignment.testConstantValue())52 }53}54extension IconPitchAlignment {55 static func testConstantValue() -> IconPitchAlignment {56 return IconPitchAlignment(rawValue: "map")!57 }58}59// MARK: ICON_ROTATION_ALIGNMENT60extension Value where T == IconRotationAlignment {61 static func testConstantValue() -> Value<IconRotationAlignment> {62 return .constant(IconRotationAlignment.testConstantValue())63 }64}65extension IconRotationAlignment {66 static func testConstantValue() -> IconRotationAlignment {67 return IconRotationAlignment(rawValue: "map")!68 }69}70// MARK: ICON_TEXT_FIT71extension Value where T == IconTextFit {72 static func testConstantValue() -> Value<IconTextFit> {73 return .constant(IconTextFit.testConstantValue())74 }75}76extension IconTextFit {77 static func testConstantValue() -> IconTextFit {78 return IconTextFit(rawValue: "none")!79 }80}81// MARK: SYMBOL_PLACEMENT82extension Value where T == SymbolPlacement {83 static func testConstantValue() -> Value<SymbolPlacement> {84 return .constant(SymbolPlacement.testConstantValue())85 }86}87extension SymbolPlacement {88 static func testConstantValue() -> SymbolPlacement {89 return SymbolPlacement(rawValue: "point")!90 }91}92// MARK: SYMBOL_Z_ORDER93extension Value where T == SymbolZOrder {94 static func testConstantValue() -> Value<SymbolZOrder> {95 return .constant(SymbolZOrder.testConstantValue())96 }97}98extension SymbolZOrder {99 static func testConstantValue() -> SymbolZOrder {100 return SymbolZOrder(rawValue: "auto")!101 }102}103// MARK: TEXT_ANCHOR104extension Value where T == TextAnchor {105 static func testConstantValue() -> Value<TextAnchor> {106 return .constant(TextAnchor.testConstantValue())107 }108}109extension TextAnchor {110 static func testConstantValue() -> TextAnchor {111 return TextAnchor(rawValue: "center")!112 }113}114// MARK: TEXT_JUSTIFY115extension Value where T == TextJustify {116 static func testConstantValue() -> Value<TextJustify> {117 return .constant(TextJustify.testConstantValue())118 }119}120extension TextJustify {121 static func testConstantValue() -> TextJustify {122 return TextJustify(rawValue: "auto")!123 }124}125// MARK: TEXT_PITCH_ALIGNMENT126extension Value where T == TextPitchAlignment {127 static func testConstantValue() -> Value<TextPitchAlignment> {128 return .constant(TextPitchAlignment.testConstantValue())129 }130}131extension TextPitchAlignment {132 static func testConstantValue() -> TextPitchAlignment {133 return TextPitchAlignment(rawValue: "map")!134 }135}136// MARK: TEXT_ROTATION_ALIGNMENT137extension Value where T == TextRotationAlignment {138 static func testConstantValue() -> Value<TextRotationAlignment> {139 return .constant(TextRotationAlignment.testConstantValue())140 }141}142extension TextRotationAlignment {143 static func testConstantValue() -> TextRotationAlignment {144 return TextRotationAlignment(rawValue: "map")!145 }146}147// MARK: TEXT_TRANSFORM148extension Value where T == TextTransform {149 static func testConstantValue() -> Value<TextTransform> {150 return .constant(TextTransform.testConstantValue())151 }152}153extension TextTransform {154 static func testConstantValue() -> TextTransform {155 return TextTransform(rawValue: "none")!156 }157}158// MARK: FILL_TRANSLATE_ANCHOR159extension Value where T == FillTranslateAnchor {160 static func testConstantValue() -> Value<FillTranslateAnchor> {161 return .constant(FillTranslateAnchor.testConstantValue())162 }163}164extension FillTranslateAnchor {165 static func testConstantValue() -> FillTranslateAnchor {166 return FillTranslateAnchor(rawValue: "map")!167 }168}169// MARK: LINE_TRANSLATE_ANCHOR170extension Value where T == LineTranslateAnchor {171 static func testConstantValue() -> Value<LineTranslateAnchor> {172 return .constant(LineTranslateAnchor.testConstantValue())173 }174}175extension LineTranslateAnchor {176 static func testConstantValue() -> LineTranslateAnchor {177 return LineTranslateAnchor(rawValue: "map")!178 }179}180// MARK: ICON_TRANSLATE_ANCHOR181extension Value where T == IconTranslateAnchor {182 static func testConstantValue() -> Value<IconTranslateAnchor> {183 return .constant(IconTranslateAnchor.testConstantValue())184 }185}186extension IconTranslateAnchor {187 static func testConstantValue() -> IconTranslateAnchor {188 return IconTranslateAnchor(rawValue: "map")!189 }190}191// MARK: TEXT_TRANSLATE_ANCHOR192extension Value where T == TextTranslateAnchor {193 static func testConstantValue() -> Value<TextTranslateAnchor> {194 return .constant(TextTranslateAnchor.testConstantValue())195 }196}197extension TextTranslateAnchor {198 static func testConstantValue() -> TextTranslateAnchor {199 return TextTranslateAnchor(rawValue: "map")!200 }201}202// MARK: CIRCLE_PITCH_ALIGNMENT203extension Value where T == CirclePitchAlignment {204 static func testConstantValue() -> Value<CirclePitchAlignment> {205 return .constant(CirclePitchAlignment.testConstantValue())206 }207}208extension CirclePitchAlignment {209 static func testConstantValue() -> CirclePitchAlignment {210 return CirclePitchAlignment(rawValue: "map")!211 }212}213// MARK: CIRCLE_PITCH_SCALE214extension Value where T == CirclePitchScale {215 static func testConstantValue() -> Value<CirclePitchScale> {216 return .constant(CirclePitchScale.testConstantValue())217 }218}219extension CirclePitchScale {220 static func testConstantValue() -> CirclePitchScale {221 return CirclePitchScale(rawValue: "map")!222 }223}224// MARK: CIRCLE_TRANSLATE_ANCHOR225extension Value where T == CircleTranslateAnchor {226 static func testConstantValue() -> Value<CircleTranslateAnchor> {227 return .constant(CircleTranslateAnchor.testConstantValue())228 }229}230extension CircleTranslateAnchor {231 static func testConstantValue() -> CircleTranslateAnchor {232 return CircleTranslateAnchor(rawValue: "map")!233 }234}235// MARK: FILL_EXTRUSION_TRANSLATE_ANCHOR236extension Value where T == FillExtrusionTranslateAnchor {237 static func testConstantValue() -> Value<FillExtrusionTranslateAnchor> {238 return .constant(FillExtrusionTranslateAnchor.testConstantValue())239 }240}241extension FillExtrusionTranslateAnchor {242 static func testConstantValue() -> FillExtrusionTranslateAnchor {243 return FillExtrusionTranslateAnchor(rawValue: "map")!244 }245}246// MARK: RASTER_RESAMPLING247extension Value where T == RasterResampling {248 static func testConstantValue() -> Value<RasterResampling> {249 return .constant(RasterResampling.testConstantValue())250 }251}252extension RasterResampling {253 static func testConstantValue() -> RasterResampling {254 return RasterResampling(rawValue: "linear")!255 }256}257// MARK: HILLSHADE_ILLUMINATION_ANCHOR258extension Value where T == HillshadeIlluminationAnchor {259 static func testConstantValue() -> Value<HillshadeIlluminationAnchor> {260 return .constant(HillshadeIlluminationAnchor.testConstantValue())261 }262}263extension HillshadeIlluminationAnchor {264 static func testConstantValue() -> HillshadeIlluminationAnchor {265 return HillshadeIlluminationAnchor(rawValue: "map")!266 }267}268// MARK: SKY_TYPE269extension Value where T == SkyType {270 static func testConstantValue() -> Value<SkyType> {271 return .constant(SkyType.testConstantValue())272 }273}274extension SkyType {275 static func testConstantValue() -> SkyType {276 return SkyType(rawValue: "gradient")!277 }278}279// MARK: MODEL_TYPE280extension Value where T == ModelType {281 static func testConstantValue() -> Value<ModelType> {282 return .constant(ModelType.testConstantValue())283 }284}285extension ModelType {286 static func testConstantValue() -> ModelType {287 return ModelType(rawValue: "common-3d")!288 }289}290// MARK: ANCHOR291extension Value where T == Anchor {292 static func testConstantValue() -> Value<Anchor> {293 return .constant(Anchor.testConstantValue())294 }295}296extension Anchor {297 static func testConstantValue() -> Anchor {298 return Anchor(rawValue: "map")!299 }300}301// MARK: NAME302extension Value where T == StyleProjectionName {303 static func testConstantValue() -> Value<StyleProjectionName> {304 return .constant(StyleProjectionName.testConstantValue())305 }306}307extension StyleProjectionName {308 static func testConstantValue() -> StyleProjectionName {309 return StyleProjectionName(rawValue: "mercator")!310 }311}312// MARK: TEXT_WRITING_MODE313extension Value where T == TextWritingMode {314 static func testConstantValue() -> Value<TextWritingMode> {315 return .constant(TextWritingMode.testConstantValue())316 }317}318extension TextWritingMode {319 static func testConstantValue() -> TextWritingMode {320 return TextWritingMode(rawValue: "horizontal")!321 }322}323// End of generated file....`

StyleManagerProtocol.swift

Source:StyleManagerProtocol.swift

`2import MapboxCoreMaps3@_implementationOnly import MapboxCommon_Private4@_implementationOnly import MapboxCoreMaps_Private5internal protocol StyleManagerProtocol {6 func asStyleManager() -> StyleManager7 func getStyleURI() -> String8 func setStyleURIForUri(_ uri: String)9 func getStyleJSON() -> String10 func setStyleJSONForJson(_ json: String)11 func getStyleDefaultCamera() -> MapboxCoreMaps.CameraOptions12 func getStyleTransition() -> MapboxCoreMaps.TransitionOptions13 func setStyleTransitionFor(_ transitionOptions: MapboxCoreMaps.TransitionOptions)14 func styleLayerExists(forLayerId layerId: String) -> Bool15 func getStyleLayers() -> [MapboxCoreMaps.StyleObjectInfo]16 func getStyleLayerProperty(forLayerId layerId: String, property: String) -> MapboxCoreMaps.StylePropertyValue17 func getStyleSourceProperty(forSourceId sourceId: String, property: String) -> MapboxCoreMaps.StylePropertyValue18 func styleSourceExists(forSourceId sourceId: String) -> Bool19 func getStyleSources() -> [MapboxCoreMaps.StyleObjectInfo]20 func getStyleLightProperty(forProperty property: String) -> MapboxCoreMaps.StylePropertyValue21 func getStyleTerrainProperty(forProperty property: String) -> MapboxCoreMaps.StylePropertyValue22 func getStyleProjectionProperty(forProperty property: String) -> MapboxCoreMaps.StylePropertyValue23 func getStyleImage(forImageId imageId: String) -> MapboxCoreMaps.Image?24 func hasStyleImage(forImageId imageId: String) -> Bool25 func isStyleLoaded() -> Bool26 func addStyleLayer(27 forProperties properties: Any,28 layerPosition: MapboxCoreMaps.LayerPosition?) -> Expected<NSNull, NSString>29 func addStyleCustomLayer(30 forLayerId layerId: String,31 layerHost: CustomLayerHost, layerPosition: MapboxCoreMaps.LayerPosition?) -> Expected<NSNull, NSString>32 func addPersistentStyleLayer(33 forProperties properties: Any,34 layerPosition: MapboxCoreMaps.LayerPosition?) -> Expected<NSNull, NSString>35 func addPersistentStyleCustomLayer(36 forLayerId layerId: String,37 layerHost: CustomLayerHost,38 layerPosition: MapboxCoreMaps.LayerPosition?) -> Expected<NSNull, NSString>39 func isStyleLayerPersistent(forLayerId layerId: String) -> Expected<NSNumber, NSString>40 func removeStyleLayer(forLayerId layerId: String) -> Expected<NSNull, NSString>41 func moveStyleLayer(42 forLayerId layerId: String,43 layerPosition: MapboxCoreMaps.LayerPosition?44 ) -> Expected<NSNull, NSString>45 func setStyleLayerPropertyForLayerId(46 _ layerId: String,47 property: String,48 value: Any) -> Expected<NSNull, NSString>49 func getStyleLayerProperties(forLayerId layerId: String) -> Expected<AnyObject, NSString>50 func setStyleLayerPropertiesForLayerId(51 _ layerId: String,52 properties: Any) -> Expected<NSNull, NSString>53 func addStyleSource(54 forSourceId sourceId: String,55 properties: Any) -> Expected<NSNull, NSString>56 func setStyleSourcePropertyForSourceId(57 _ sourceId: String,58 property: String,59 value: Any) -> Expected<NSNull, NSString>60 func getStyleSourceProperties(forSourceId sourceId: String) -> Expected<AnyObject, NSString>61 func setStyleSourcePropertiesForSourceId(62 _ sourceId: String,63 properties: Any) -> Expected<NSNull, NSString>64 func updateStyleImageSourceImage(65 forSourceId sourceId: String,66 image: Image) -> Expected<NSNull, NSString>67 func removeStyleSource(forSourceId sourceId: String) -> Expected<NSNull, NSString>68 func setStyleLightForProperties(_ properties: Any) -> Expected<NSNull, NSString>69 func setStyleLightPropertyForProperty(70 _ property: String,71 value: Any) -> Expected<NSNull, NSString>72 @discardableResult73 func setStyleTerrainForProperties(_ properties: Any) -> Expected<NSNull, NSString>74 func setStyleTerrainPropertyForProperty(75 _ property: String,76 value: Any) -> Expected<NSNull, NSString>77 func setStyleProjectionForProperties(_ properties: Any) -> Expected<NSNull, NSString>78 func setStyleProjectionPropertyForProperty(79 _ property: String,80 value: Any) -> Expected<NSNull, NSString>81 // swiftlint:disable:next function_parameter_count82 func addStyleImage(83 forImageId imageId: String,84 scale: Float,85 image: Image,86 sdf: Bool,87 stretchX: [ImageStretches],88 stretchY: [ImageStretches],89 content: ImageContent?) -> Expected<NSNull, NSString>90 func removeStyleImage(forImageId imageId: String) -> Expected<NSNull, NSString>91 func addStyleCustomGeometrySource(92 forSourceId sourceId: String,93 options: CustomGeometrySourceOptions) -> Expected<NSNull, NSString>94 func setStyleCustomGeometrySourceTileDataForSourceId(95 _ sourceId: String,96 tileId: CanonicalTileID,97 featureCollection: [MapboxCommon.Feature]) -> Expected<NSNull, NSString>98 func invalidateStyleCustomGeometrySourceTile(99 forSourceId sourceId: String,100 tileId: CanonicalTileID) -> Expected<NSNull, NSString>101 func invalidateStyleCustomGeometrySourceRegion(102 forSourceId sourceId: String,103 bounds: CoordinateBounds) -> Expected<NSNull, NSString>104}105// MARK: Conformance106extension StyleManager: StyleManagerProtocol {107 func asStyleManager() -> StyleManager {108 return self109 }110}...`

TopLevelFunctions.swift

Source:TopLevelFunctions.swift

`...7 override var isFlipped: Bool {8 return true9 }10}11//: These top-level functions call through to the private bot and recorder instances above, to make the playground more accessible.12public func startBot() {13 let boogieView = FlippedView(frame: bot.bounds)14 boogieView.wantsLayer = true15 bot.backgroundColor = NSColor.black.cgColor16 boogieView.layer?.addSublayer(bot)17 PlaygroundPage.current.liveView = boogieView18 if let scale = boogieView.window?.backingScaleFactor {19 bot.setScale(scale)20 }21 recorder.targetView = boogieView22}23public func runBoogieBotDemoMode() {24 startBot()25 bot.runDemoMode()26}27public func startRecording() {28 recorder.recordingLayer = bot29 recorder.scale = 0.530 recorder.startRecording()31 bot.boogieDelegate = recorder32}33public func leftArmUp() {34 bot.doMove(.leftArmUp)35}36public func leftArmDown() {37 bot.doMove(.leftArmDown)38}39public func rightArmUp() {40 bot.doMove(.rightArmUp)41}42public func rightArmDown() {43 bot.doMove(.rightArmDown)44}45public func leftLegUp() {46 bot.doMove(.leftLegUp)47}48public func leftLegDown() {49 bot.doMove(.leftLegDown)50}51public func rightLegUp() {52 bot.doMove(.rightLegUp)53}54public func rightLegDown() {55 bot.doMove(.rightLegDown)56}57public func shakeItLeft() {58 bot.doMove(.shakeItLeft)59}60public func shakeItRight() {61 bot.doMove(.shakeItRight)62}63public func shakeItCenter() {64 bot.doMove(.shakeItCenter)65}66public func jumpUp() {67 bot.doMove(.jumpUp)68}69public func jumpDown() {70 bot.doMove(.jumpDown)71}72public func fabulize() {73 bot.doMove(.fabulize)74}75public func defabulize() {76 bot.doMove(.defabulize)77}78public func setBotTitle(_ botTitle: String) {79 bot.title = botTitle80}81public func setBotSubtitle(_ subtitle: String) {82 bot.subtitle = subtitle83}...`

func

Using AI Code Generation

`1import Mockingbird2import Mockingbird3import Mockingbird4import Mockingbird5import Mockingbird6import Mockingbird7import Mockingbird8import Mockingbird9import Mockingbird10import Mockingbird11import Mockingbird12import Mockingbird13import Mockingbird14import Mockingbird15import Mockingbird16import Mockingbird17import Mockingbird18import Mockingbird19import Mockingbird20import Mockingbird21import Mockingbird22import Mockingbird23import Mockingbird24import Mockingbird25import Mockingbird`

func

Using AI Code Generation

`1import Mockingbird2let mock = Mockingbird()3mock.sayHello()4import Mockingbird5let mock Mockingbird()6mock.sayHello()7import Mockingbird8let mock Mockingbird()9mock.sayHello()10import Mockingbird11let mock Mockingbird()12mock.sayHello()13import Mockingbird14let mock = Mockingbird()15mock.sayHello()16import Mockingbird17let mock = Mockingbird()18mock.sayHello()19import Mockingbird20let mock = Mockingbird()21mock.sayHello()`

func

Using AI Code Generation

`1import Mockingbird2class MockingbirdClass {3 func getBird() -> String {4 }5}6class MockingbirdClassTest {7 func testGetBird() {8 let mockingbirdClass = MockingbirdClass()9 let result = mockingbirdClass.getBird()10 XCTAssertEqual(result, "Mockingbird")11 }12}13class MockingbirdClassTest2 {14 func testGetBird() {15 let mockingbirdClass = MockingbirdClass()16 let result = mockingbirdClass.getBird()17 XCTAssertEqual(result, "Mockingbird")18 }19}20class MockingbirdClassTest3 {21 func testGetBird() {22 let mockingbirdClass = MockingbirdClass()23 let result = mockingbirdClass.getBird()24 XCTAssertEqual(result, "Mockingbird")25 }26}27class MockingbirdClassTest4 {28 func testGetBird() {29 let mockingbirdClass = MockingbirdClass()30 let result = mockingbirdClass.getBird()31 XCTAssertEqual(result, "Mockingbird")32 }33}34class MockingbirdClassTest5 {35 func testGetBird() {36 let mockingbirdClass = MockingbirdClass()37 let result = mockingbirdClass.getBird()38 XCTAssertEqual(result, "Mockingbird")39 }40}41class MockingbirdClassTest6 {42 func testGetBird() {43 let mockingbirdClass = MockingbirdClass()44 let result = mockingbirdClass.getBird()45 XCTAssertEqual(result, "Mockingbird")46 }47}48class MockingbirdClassTest7 {49 func testGetBird() {50 let mockingbirdClass = MockingbirdClass()51 let result = mockingbirdClass.getBird()52 XCTAssertEqual(result, "Mockingbird")53 }54}55class MockingbirdClassTest8 {56 func testGetBird() {57 let mockingbirdClass = MockingbirdClass()58import Mockingbird59let mock = Mockingbird()60mock.sayHello()61import Mockingbird62let mock = Mockingbird()63mock.sayHello()64import Mockingbird65let mock = Mockingbird()66mock.sayHello()67import Mockingbird68let mock = Mockingbird()69mock.sayHello()70import Mockingbird71let mock = Mockingbird()72mock.sayHello()73import Mockingbird74let mock = Mockingbird()75mock.sayHello()76import Mockingbird77let mock = Mockingbird()78mock.sayHello()79import Mockingbird`

func

Using AI Code Generation

`1let mock = Mockingbird()2mock.sayHello()3import Mockingbird4let mock = Mockingbird()5mock.sayHello()6import Mockingbird7let mock = Mockingbird()8mock.sayHello()9import Mockingbird10let mock = Mockingbird()11mock.sayHello()12import Mockingbird13let mock = Mockingbird()14mock.sayHello()15import Mockingbird16let mock = Mockingbird()17mock.sayHello()18import Mockingbird19let mock = Mockingbird()20mock.sayHello()21import Mockingbird22let mock = Mockingbird()23mock.sayHello()24import Mockingbird25let mock = Mockingbird()26mock.sayHello()27import Mockingbird28let mock = Mockingbird()29mock.sayHello()30import Mockingbird31let mock = Mockingbird()32mock.sayHello()33import Mockingbird34let mock = Mockingbird()35mock.sayHello()36import Mockingbird37let mock = Mockingbird()`

func

Using AI Code Generation

`1class MockingbirdExample {2 func test() {3 let mock = Mockingbird.mock(MyClass.self)4 mock.expect("hello").andReturn("world")5 let result = mock.hello()6 print(result)7 mock.verify()8 }9}10class MockingbirdExample {11 func test() {12 let mock = MockingbirdFramework.mock(MyClass.self)13 mock.expect("hello").andReturn("world")14 let result = mock.hello()15 print(result)16 mock.verify()17 }18}19Mockingbird is released under the MIT license. See [LICENSE](LICENSE) for details.lo()20import Mockingbird21let mock = Mockingbird()22mock.sayHello()23import Mockingbird`

func

Using AI Code Generation

`1import Mockingbird2import XCTest3class MockingbirdTests: XCTestCase {4 func testExample() {5 let mock = MockExample()6 stub(mock) { mock in7 when(mock.aFunction()).thenReturn(1)8 }9 XCTAssertEqual(mock.aFunction(), 1)10 }11}12import Mockingbird13import XCTest14class MockingbirdTests: XCTestCase {15 func testExample() {16 let mock = MockExample()17 stub(mock) { mock in18 when(mock.aFunction()).thenReturn(1)19 }20 XCTAssertEqual(mock.aFunction(), 1)21 }22}23import Mockingbird24import XCTest25class MockingbirdTests: XCTestCase {26 func testExample() {27 let mock = MockExample()28 stub(mock) { mock in29 when(mock.aFunction()).thenReturn(1)30 }31 XCTAssertEqual(mock.aFunction(), 1)32 }33}34import Mockingbird35import XCTest36class MockingbirdTests: XCTestCase {37 func testExample() {38 let mock = MockExample()39 stub(mock) { mock in40 when(mock.aFunction()).thenReturn(1)41 }42 XCTAssertEqual(mock.aFunction(), 1)43 }44}45import Mockingbird46import XCTest47class MockingbirdTests: XCTestCase {48 func testExample() {49 let mock = MockExample()50 stub(mock) { mock in51 when(mock.aFunction()).thenReturn(1)52 }53 XCTAssertEqual(mock.aFunction(), 1)54 }55}56import Mockingbird57import XCTest58class MockingbirdTests: XCTestCase {59 func testExample() {60 let mock = MockExample()61 stub(mock) { mock in62 when(mock.aFunction()).thenReturn(1)63 }64 XCTAssertEqual(mock.aFunction(), 1)65 }66}67import Mockingbird68import XCTest69class MockingbirdTests: XCTestCase {70 func testExample() {`

func

Using AI Code Generation

`1class MockingbirdExample {2 func test() {3 let mock = Mockingbird.mock(MyClass.self)4 mock.expect("hello").andReturn("world")5 let result = mock.hello()6 print(result)7 mock.verify()8 }9}10class MockingbirdExample {11 func test() {12 let mock = MockingbirdFramework.mock(MyClass.self)13 mock.expect("hello").andReturn("world")14 let result = mock.hello()15 print(result)16 mock.verify()17 }18}`

## Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.