How to use until method of func class

Best Nimble code snippet using func.until

Observable+TakeUntilTests.swift

Source:Observable+TakeUntilTests.swift Github

copy

Full Screen

1//2// Observable+TakeUntilTests.swift3// Tests4//5// Created by Krunoslav Zaher on 4/29/17.6// Copyright © 2017 Krunoslav Zaher. All rights reserved.7//8import XCTest9import RxSwift10import RxTest11class ObservableTakeUntilTest : RxTest {12}13extension ObservableTakeUntilTest {14 func testTakeUntil_Preempt_SomeData_Next() {15 let scheduler = TestScheduler(initialClock: 0)16 17 let l = scheduler.createHotObservable([18 .next(150, 1),19 .next(210, 2),20 .next(220, 3),21 .next(230, 4),22 .next(240, 5),23 .completed(250)24 ])25 26 let r = scheduler.createHotObservable([27 .next(150, 1),28 .next(225, 99),29 .completed(230)30 ])31 32 let res = scheduler.start {33 l.takeUntil(r)34 }35 36 XCTAssertEqual(res.events, [37 .next(210, 2),38 .next(220, 3),39 .completed(225)40 ])41 42 XCTAssertEqual(l.subscriptions, [43 Subscription(200, 225)44 ])45 XCTAssertEqual(r.subscriptions, [46 Subscription(200, 225)47 ])48 }49 50 func testTakeUntil_Preempt_SomeData_Error() {51 let scheduler = TestScheduler(initialClock: 0)52 53 let l = scheduler.createHotObservable([54 .next(150, 1),55 .next(210, 2),56 .next(220, 3),57 .next(230, 4),58 .next(240, 5),59 .completed(250)60 ])61 62 let r = scheduler.createHotObservable([63 .next(150, 1),64 .error(225, testError),65 ])66 67 let res = scheduler.start {68 l.takeUntil(r)69 }70 XCTAssertEqual(res.events, [71 .next(210, 2),72 .next(220, 3),73 .error(225, testError)74 ])75 76 XCTAssertEqual(l.subscriptions, [77 Subscription(200, 225)78 ])79 80 XCTAssertEqual(r.subscriptions, [81 Subscription(200, 225)82 ])83 }84 85 func testTakeUntil_NoPreempt_SomeData_Empty() {86 let scheduler = TestScheduler(initialClock: 0)87 88 let l = scheduler.createHotObservable([89 .next(150, 1),90 .next(210, 2),91 .next(220, 3),92 .next(230, 4),93 .next(240, 5),94 .completed(250)95 ])96 97 let r = scheduler.createHotObservable([98 .next(150, 1),99 .completed(225)100 ])101 102 let res = scheduler.start {103 l.takeUntil(r)104 }105 106 XCTAssertEqual(res.events, [107 .next(210, 2),108 .next(220, 3),109 .next(230, 4),110 .next(240, 5),111 .completed(250)112 ])113 114 XCTAssertEqual(l.subscriptions, [115 Subscription(200, 250)116 ])117 118 XCTAssertEqual(r.subscriptions, [119 Subscription(200, 225)120 ])121 }122 123 func testTakeUntil_NoPreempt_SomeData_Never() {124 let scheduler = TestScheduler(initialClock: 0)125 126 let l = scheduler.createHotObservable([127 .next(150, 1),128 .next(210, 2),129 .next(220, 3),130 .next(230, 4),131 .next(240, 5),132 .completed(250)133 ])134 135 let r = scheduler.createHotObservable([136 .next(150, 1),137 ])138 139 let res = scheduler.start {140 l.takeUntil(r)141 }142 143 XCTAssertEqual(res.events, [144 .next(210, 2),145 .next(220, 3),146 .next(230, 4),147 .next(240, 5),148 .completed(250)149 ])150 151 XCTAssertEqual(l.subscriptions, [152 Subscription(200, 250)153 ])154 155 XCTAssertEqual(r.subscriptions, [156 Subscription(200, 250)157 ])158 }159 160 func testTakeUntil_Preempt_Never_Next() {161 let scheduler = TestScheduler(initialClock: 0)162 163 let l = scheduler.createHotObservable([164 .next(150, 1),165 ])166 167 let r = scheduler.createHotObservable([168 .next(150, 1),169 .next(225, 2),170 .completed(250)171 ])172 173 let res = scheduler.start {174 l.takeUntil(r)175 }176 177 XCTAssertEqual(res.events, [178 .completed(225)179 ])180 181 XCTAssertEqual(l.subscriptions, [182 Subscription(200, 225)183 ])184 185 XCTAssertEqual(r.subscriptions, [186 Subscription(200, 225)187 ])188 }189 190 func testTakeUntil_Preempt_Never_Error() {191 let scheduler = TestScheduler(initialClock: 0)192 193 let l = scheduler.createHotObservable([194 .next(150, 1),195 ])196 197 let r = scheduler.createHotObservable([198 .next(150, 1),199 .error(225, testError)200 ])201 202 let res = scheduler.start {203 l.takeUntil(r)204 }205 206 XCTAssertEqual(res.events, [207 .error(225, testError)208 ])209 210 XCTAssertEqual(l.subscriptions, [211 Subscription(200, 225)212 ])213 214 XCTAssertEqual(r.subscriptions, [215 Subscription(200, 225)216 ])217 }218 func testTakeUntil_NoPreempt_Never_Empty() {219 let scheduler = TestScheduler(initialClock: 0)220 221 let l = scheduler.createHotObservable([222 .next(150, 1),223 ])224 225 let r = scheduler.createHotObservable([226 .next(150, 1),227 .completed(225)228 ])229 230 let res = scheduler.start {231 l.takeUntil(r)232 }233 234 XCTAssertEqual(res.events, [235 ])236 237 XCTAssertEqual(l.subscriptions, [238 Subscription(200, 1000)239 ])240 241 XCTAssertEqual(r.subscriptions, [242 Subscription(200, 225)243 ])244 }245 246 func testTakeUntil_NoPreempt_Never_Never() {247 let scheduler = TestScheduler(initialClock: 0)248 249 let l = scheduler.createHotObservable([250 .next(150, 1),251 ])252 253 let r = scheduler.createHotObservable([254 .next(150, 1),255 ])256 257 let res = scheduler.start {258 l.takeUntil(r)259 }260 261 XCTAssertEqual(res.events, [262 ])263 264 XCTAssertEqual(l.subscriptions, [265 Subscription(200, 1000)266 ])267 268 XCTAssertEqual(r.subscriptions, [269 Subscription(200, 1000)270 ])271 }272 273 func testTakeUntil_Preempt_BeforeFirstProduced() {274 let scheduler = TestScheduler(initialClock: 0)275 276 let l = scheduler.createHotObservable([277 .next(150, 1),278 .next(230, 2),279 .completed(240)280 ])281 282 let r = scheduler.createHotObservable([283 .next(150, 1),284 .next(210, 2),285 .completed(220)286 ])287 288 let res = scheduler.start {289 l.takeUntil(r)290 }291 292 XCTAssertEqual(res.events, [293 .completed(210)294 ])295 296 XCTAssertEqual(l.subscriptions, [297 Subscription(200, 210)298 ])299 300 XCTAssertEqual(r.subscriptions, [301 Subscription(200, 210)302 ])303 }304 305 func testTakeUntil_Preempt_BeforeFirstProduced_RemainSilentAndProperDisposed() {306 let scheduler = TestScheduler(initialClock: 0)307 308 let l = scheduler.createHotObservable([309 .next(150, 1),310 .error(215, testError),311 .completed(240)312 ])313 314 let r = scheduler.createHotObservable([315 .next(150, 1),316 .next(210, 2),317 .completed(220)318 ])319 320 var sourceNotDisposed = false321 322 let res = scheduler.start {323 l.do(onNext: { _ in sourceNotDisposed = true }).takeUntil(r)324 }325 326 XCTAssertEqual(res.events, [327 .completed(210)328 ])329 330 XCTAssertFalse(sourceNotDisposed)331 }332 333 func testTakeUntil_NoPreempt_AfterLastProduced_ProperDisposedSigna() {334 let scheduler = TestScheduler(initialClock: 0)335 336 let l = scheduler.createHotObservable([337 .next(150, 1),338 .next(230, 2),339 .completed(240)340 ])341 342 let r = scheduler.createHotObservable([343 .next(150, 1),344 .next(250, 2),345 .completed(260)346 ])347 348 var sourceNotDisposed = false349 350 let res = scheduler.start {351 l.takeUntil(r.do(onNext: { _ in sourceNotDisposed = true }))352 }353 354 XCTAssertEqual(res.events, [355 .next(230, 2),356 .completed(240)357 ])358 359 XCTAssertFalse(sourceNotDisposed)360 }361 362 func testTakeUntil_Error_Some() {363 let scheduler = TestScheduler(initialClock: 0)364 365 let l = scheduler.createHotObservable([366 .next(150, 1),367 .error(225, testError)368 ])369 370 let r = scheduler.createHotObservable([371 .next(150, 1),372 .next(240, 2),373 ])374 375 let sourceNotDisposed = false376 377 let res = scheduler.start {378 l.takeUntil(r)379 }380 381 XCTAssertEqual(res.events, [382 .error(225, testError),383 ])384 385 XCTAssertFalse(sourceNotDisposed)386 }387 #if TRACE_RESOURCES388 func testTakeUntil1ReleasesResourcesOnComplete() {389 let scheduler = TestScheduler(initialClock: 0)390 _ = Observable.just(1).delay(10, scheduler: scheduler).takeUntil(Observable.just(1)).subscribe()391 scheduler.start()392 }393 func testTakeUntil2ReleasesResourcesOnComplete() {394 let scheduler = TestScheduler(initialClock: 0)395 _ = Observable.just(1).takeUntil(Observable.just(1).delay(10, scheduler: scheduler)).subscribe()396 scheduler.start()397 }398 func testTakeUntil1ReleasesResourcesOnError() {399 let scheduler = TestScheduler(initialClock: 0)400 _ = Observable<Int>.never().timeout(20, scheduler: scheduler).takeUntil(Observable<Int>.never()).subscribe()401 scheduler.start()402 }403 func testTakeUntil2ReleasesResourcesOnError() {404 let scheduler = TestScheduler(initialClock: 0)405 _ = Observable<Int>.never().takeUntil(Observable<Int>.never().timeout(20, scheduler: scheduler)).subscribe()406 scheduler.start()407 }408 #endif409}...

Full Screen

Full Screen

Observable+SkipUntilTests.swift

Source:Observable+SkipUntilTests.swift Github

copy

Full Screen

1//2// Observable+SkipUntilTests.swift3// Tests4//5// Created by Krunoslav Zaher on 4/29/17.6// Copyright © 2017 Krunoslav Zaher. All rights reserved.7//8import XCTest9import RxSwift10import RxTest11class ObservableSkipUntilTest : RxTest {12}13extension ObservableSkipUntilTest {14 func testSkipUntil_SomeData_Next() {15 let scheduler = TestScheduler(initialClock: 0)16 17 let l = scheduler.createHotObservable([18 .next(150, 1),19 .next(210, 2),20 .next(220, 3),21 .next(230, 4), //!22 .next(240, 5), //!23 .completed(250)24 ])25 26 let r = scheduler.createHotObservable([27 .next(150, 1),28 .next(225, 99),29 .completed(230)30 ])31 32 let res = scheduler.start {33 l.skipUntil(r)34 }35 36 XCTAssertEqual(res.events, [37 .next(230, 4),38 .next(240, 5),39 .completed(250)40 ])41 42 XCTAssertEqual(l.subscriptions, [43 Subscription(200, 250)44 ])45 XCTAssertEqual(r.subscriptions, [46 Subscription(200, 225)47 ])48 }49 50 func testSkipUntil_SomeData_Error() {51 let scheduler = TestScheduler(initialClock: 0)52 53 let l = scheduler.createHotObservable([54 .next(150, 1),55 .next(210, 2),56 .next(220, 3),57 .next(230, 4),58 .next(240, 5),59 .completed(250)60 ])61 62 let r = scheduler.createHotObservable([63 .next(150, 1),64 .error(225, testError)65 ])66 67 let res = scheduler.start {68 l.skipUntil(r)69 }70 71 XCTAssertEqual(res.events, [72 .error(225, testError),73 ])74 75 XCTAssertEqual(l.subscriptions, [76 Subscription(200, 225)77 ])78 XCTAssertEqual(r.subscriptions, [79 Subscription(200, 225)80 ])81 }82 83 func testSkipUntil_Error_SomeData() {84 let scheduler = TestScheduler(initialClock: 0)85 86 let l = scheduler.createHotObservable([87 .next(150, 1),88 .next(210, 2),89 .error(220, testError)90 91 ])92 93 let r = scheduler.createHotObservable([94 .next(150, 1),95 .next(230, 2),96 .completed(250)97 ])98 99 let res = scheduler.start {100 l.skipUntil(r)101 }102 103 XCTAssertEqual(res.events, [104 .error(220, testError),105 ])106 107 XCTAssertEqual(l.subscriptions, [108 Subscription(200, 220)109 ])110 XCTAssertEqual(r.subscriptions, [111 Subscription(200, 220)112 ])113 }114 115 func testSkipUntil_SomeData_Empty() {116 let scheduler = TestScheduler(initialClock: 0)117 118 let l = scheduler.createHotObservable([119 .next(150, 1),120 .next(210, 2),121 .next(220, 3),122 .next(230, 4),123 .next(240, 5),124 .completed(250)125 ])126 127 let r = scheduler.createHotObservable([128 .next(150, 1),129 .completed(225)130 ])131 132 let res = scheduler.start {133 l.skipUntil(r)134 }135 136 XCTAssertEqual(res.events, [137 ])138 139 XCTAssertEqual(l.subscriptions, [140 Subscription(200, 250)141 ])142 XCTAssertEqual(r.subscriptions, [143 Subscription(200, 225)144 ])145 }146 147 func testSkipUntil_Never_Next() {148 let scheduler = TestScheduler(initialClock: 0)149 150 let l = scheduler.createHotObservable([151 .next(150, 1)152 ])153 154 let r = scheduler.createHotObservable([155 .next(150, 1),156 .next(225, 2), //!157 .completed(250)158 ])159 160 let res = scheduler.start {161 l.skipUntil(r)162 }163 164 XCTAssertEqual(res.events, [165 ])166 167 XCTAssertEqual(l.subscriptions, [168 Subscription(200, 1000)169 ])170 XCTAssertEqual(r.subscriptions, [171 Subscription(200, 225)172 ])173 }174 175 func testSkipUntil_Never_Error1() {176 let scheduler = TestScheduler(initialClock: 0)177 178 let l = scheduler.createHotObservable([179 .next(150, 1)180 ])181 182 let r = scheduler.createHotObservable([183 .next(150, 1),184 .error(225, testError)185 ])186 187 let res = scheduler.start {188 l.skipUntil(r)189 }190 191 XCTAssertEqual(res.events, [192 .error(225, testError)193 ])194 195 XCTAssertEqual(l.subscriptions, [196 Subscription(200, 225)197 ])198 XCTAssertEqual(r.subscriptions, [199 Subscription(200, 225)200 ])201 }202 203 func testSkipUntil_SomeData_Error2() {204 let scheduler = TestScheduler(initialClock: 0)205 206 let l = scheduler.createHotObservable([207 .next(150, 1),208 .next(210, 2),209 .next(220, 3),210 .next(230, 4),211 .next(240, 5),212 .completed(250)213 ])214 215 let r = scheduler.createHotObservable([216 .next(150, 1),217 .error(300, testError)218 ])219 220 let res = scheduler.start {221 l.skipUntil(r)222 }223 224 XCTAssertEqual(res.events, [225 ])226 227 XCTAssertEqual(l.subscriptions, [228 Subscription(200, 250)229 ])230 XCTAssertEqual(r.subscriptions, [231 Subscription(200, 250)232 ])233 }234 235 func testSkipUntil_SomeData_Never() {236 let scheduler = TestScheduler(initialClock: 0)237 238 let l = scheduler.createHotObservable([239 .next(150, 1),240 .next(210, 2),241 .next(220, 3),242 .next(230, 4),243 .next(240, 5),244 .completed(250)245 ])246 247 let r = scheduler.createHotObservable([248 .next(150, 1),249 ])250 251 let res = scheduler.start {252 l.skipUntil(r)253 }254 255 XCTAssertEqual(res.events, [256 ])257 258 XCTAssertEqual(l.subscriptions, [259 Subscription(200, 250)260 ])261 XCTAssertEqual(r.subscriptions, [262 Subscription(200, 250)263 ])264 }265 266 func testSkipUntil_Never_Empty() {267 let scheduler = TestScheduler(initialClock: 0)268 269 let l = scheduler.createHotObservable([270 .next(150, 1),271 ])272 273 let r = scheduler.createHotObservable([274 .next(150, 1),275 .completed(225)276 ])277 278 let res = scheduler.start {279 l.skipUntil(r)280 }281 282 XCTAssertEqual(res.events, [283 ])284 285 XCTAssertEqual(l.subscriptions, [286 Subscription(200, 1000)287 ])288 289 XCTAssertEqual(r.subscriptions, [290 Subscription(200, 225)291 ])292 }293 294 func testSkipUntil_Never_Never() {295 let scheduler = TestScheduler(initialClock: 0)296 297 let l = scheduler.createHotObservable([298 .next(150, 1),299 ])300 301 let r = scheduler.createHotObservable([302 .next(150, 1),303 ])304 305 let res = scheduler.start {306 l.skipUntil(r)307 }308 309 XCTAssertEqual(res.events, [310 ])311 312 XCTAssertEqual(l.subscriptions, [313 Subscription(200, 1000)314 ])315 XCTAssertEqual(r.subscriptions, [316 Subscription(200, 1000)317 ])318 }319 320 func testSkipUntil_HasCompletedCausesDisposal() {321 let scheduler = TestScheduler(initialClock: 0)322 323 var isDisposed = false324 325 let l = scheduler.createHotObservable([326 .next(150, 1),327 .next(210, 2),328 .next(220, 3),329 .next(230, 4),330 .next(240, 5),331 .completed(250)332 ])333 334 let r: Observable<Int> = Observable.create { o in335 return Disposables.create {336 isDisposed = true337 }338 }339 340 let res = scheduler.start {341 l.skipUntil(r)342 }343 344 XCTAssertEqual(res.events, [345 ])346 347 XCTAssert(isDisposed, "isDisposed")348 }349 #if TRACE_RESOURCES350 func testSkipUntilReleasesResourcesOnComplete1() {351 let scheduler = TestScheduler(initialClock: 0)352 _ = Observable<Int>.just(1).delay(20, scheduler: scheduler).skipUntil(Observable<Int>.just(1)).subscribe()353 scheduler.start()354 }355 func testSkipUntilReleasesResourcesOnComplete2() {356 let scheduler = TestScheduler(initialClock: 0)357 _ = Observable<Int>.just(1).skipUntil(Observable<Int>.just(1).delay(20, scheduler: scheduler)).subscribe()358 scheduler.start()359 }360 func testSkipUntilReleasesResourcesOnError1() {361 let scheduler = TestScheduler(initialClock: 0)362 _ = Observable<Int>.never().timeout(20, scheduler: scheduler).skipUntil(Observable<Int>.just(1)).subscribe()363 scheduler.start()364 }365 func testSkipUntilReleasesResourcesOnError2() {366 let scheduler = TestScheduler(initialClock: 0)367 _ = Observable<Int>.just(1).skipUntil(Observable<Int>.never().timeout(20, scheduler: scheduler)).subscribe()368 scheduler.start()369 }370 #endif371}...

Full Screen

Full Screen

until

Using AI Code Generation

copy

Full Screen

1func getDistance(x1: Double, y1: Double, x2: Double, y2: Double) -> Double {2 let distance = sqrt(pow(x, 2) + pow(y, 2))3}4func getAngle(x1: Double, y1: Double, x2: Double, y2: Double) -> Double {5 let angle = atan2(y, x)6}7func getAngle(x1: Double, y1: Double, x2: Double, y2: Double) -> Double {8 let angle = atan2(y, x)9}10func getDistance(x1: Double, y1: Double, x2: Double, y2: Double) -> Double {11 let distance = sqrt(pow(x, 2) + pow(y, 2))12}13func getAngle(x1: Double, y1: Double, x2: Double, y2: Double) -> Double {14 let angle = atan2(y, x)15}16func getDistance(x1: Double, y1: Double, x2: Double, y2: Double) -> Double {17 let distance = sqrt(pow(x, 2) + pow(y, 2))18}

Full Screen

Full Screen

until

Using AI Code Generation

copy

Full Screen

1import Foundation2func hello() {3 print("Hello World")4}5hello()6import Foundation7func hello() {8 print("Hello World")9}10hello()11import Foundation12func hello() {13 print("Hello World")14}15hello()16import Foundation17func hello() {18 print("Hello World")19}20hello()21import Foundation22func hello() {23 print("Hello World")24}25hello()26import Foundation27func hello() {28 print("Hello World")29}30hello()31import Foundation32func hello() {33 print("Hello World")34}35hello()36import Foundation37func hello() {38 print("Hello World")39}40hello()41import Foundation42func hello() {43 print("Hello World")44}45hello()46import Foundation47func hello() {48 print("Hello World")49}50hello()51import Foundation52func hello() {53 print("Hello World")54}55hello()56import Foundation57func hello() {58 print("Hello World")59}60hello()61import Foundation62func hello() {63 print("Hello World")64}65hello()66import Foundation67func hello() {68 print("Hello World")69}70hello()71import Foundation72func hello() {73 print("Hello World")74}75hello()76import Foundation77func hello() {78 print("Hello World")79}80hello()81import Foundation82func hello() {83 print("Hello World")84}85hello()86import Foundation87func hello() {88 print("Hello World")89}90hello()91import Foundation92func hello() {93 print("Hello World")94}95hello()96import Foundation97func hello() {98 print("Hello World")99}100hello()101import Foundation102func hello() {103 print("Hello World")104}105hello()106import Foundation107func hello() {108 print("Hello World")109}110hello()111import Foundation112func hello() {113 print("Hello World")114}115hello()116import Foundation117func hello() {118 print("

Full Screen

Full Screen

until

Using AI Code Generation

copy

Full Screen

1import Foundation2class Person {3 func display() {4 print("name = \(name), age = \(age)")5 }6 func input() {7 }8}9var p = Person()10p.input()11p.display()

Full Screen

Full Screen

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful