text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_suffix|>scala.reflect.macros.blackbox private[zio] abstract class HasNoScopeCompanionVersionSpecific { val instance: HasNoScope[Any] implicit def noScope[R]: HasNoScope[R] = macro HasNoScopeMacro.impl[R] } private[zio] class HasNoScopeMacro(val c: blackbox.Context) { import c.universe._ /** * ...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2021-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
/* * Copyright 2017-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless requir...
fim
zio/zio
scala
<|fim_prefix|>package zio privat<|fim_suffix|>A]: Tag[A] = macro zio.internal.macros.InternalMacros.materializeTag[A] } <|fim_middle|>e[zio] trait TagVersionSpecific { implicit def materialize[<|endoftext|>
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2021-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
<|fim_prefix|>package zio private[zio] trait ZIOAppVersionSpecific { /** * This implicit conversion macro will ensure that the provided ZIO effect * does not require more than the provided environme<|fim_suffix|>nal.macros.LayerMacros.validate[R1, R] } <|fim_middle|>nt. * * If it is missing requirement...
fim
zio/zio
scala
<|fim_suffix|>n a catch-try block. Useful for handling cases * where the user-provided effect might throw outside the ZIO effect, but we * don't want to incur the performance penalty from the additional flatMap in * `ZIO.suspend`. */ @inline final protected def attemptOrDieZIO[R, E, A](effect: => ZIO[R,...
fim
zio/zio
scala
<|fim_suffix|>* * {{{ * val clockLayer: ZLayer[Any, Nothing, Clock] = ??? * * val zio: ZIO[Clock with Random, Nothing, Unit] = ??? * * val zio2 = zio.provideSome[Random](clockLayer) * }}} */ def provideSome[R0]: ProvideSomeLayerPartiallyApplied[R0, R, E, A] = new ProvideSomeLayerPartiallyA...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2017-2020 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
<|fim_suffix|>eOfOutput Unit): ZIO[Any, E1, Unit] = macro ZLayerMakeMacros.runWithImpl[R, E1, A] } <|fim_prefix|>package zio import zio.i<|fim_middle|>nternal.macros.ZLayerMakeMacros private[zio] trait ZLayerVersionSpecific[-R, +E, +A] { self: ZLayer[R, E, A] => def runWith[E1 >: E](layers: ZLayer[_, E1, _]*)...
fim
zio/zio
scala
<|fim_suffix|> Function( newArgs, clean(c)( tree, ctx.withFuncSyntheticArgs(synthetic.collect { case ValDef(_, TermName(name), _, _) => name }.toSet) ) ) case t => t } } private def cleanTupleTerm(n: String) = ...
fim
zio/zio
scala
package zio.internal.macros import zio.{IsReloadable, ScopedRef} import scala.reflect.macros.blackbox class IsReloadableMacros(val c: blackbox.Context) { import c.universe._ def makeImpl[A: c.WeakTypeTag]: c.Expr[IsReloadable[A]] = { val tpe = c.weakTypeOf[A] def unsupported(reason: String): Nothing = ...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal.macros import zio._ import zio.internal.TerminalRendering import scala.reflect.macros.blackbox private[zio] trait LayerMacroUtils { val c: blackbox.Context import c.universe._ type LayerExpr = Expr[ZLayer[_, _, _]] private def verifyLayers(layers: Seq[LayerExpr]): Unit = ...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal.macros import zio._ import zio.internal.TerminalRendering import zio.internal.ansi.AnsiStringOps import scala.reflect.macros.blackbox private[zio] class LayerMacros(val c: blackbox.Context) extends LayerMacroUtils { import c.universe._ def validate[Provided: WeakTypeTag, Requi...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal.macros import zio._ import scala.reflect.macros.whitebox private[zio] class ZLayerDerivationMacros(val c: whitebox.Context) { import c.universe._ case class Param(tpe: Type, name: TermName, defaultOrService: Either[Type, Tree], rType: Type, eType: Opt<|fim_suffix|>t[${p.tpe}]" ...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal.macros import zio.internal.ansi.AnsiStringOps import zio.ZLayer import scala.reflect.macros.blackbox import zio.ZIO import zio.IsSubtypeOfOutput final class ZLayerMakeMacros(val c: blackbox.Context) extends LayerMacroUtils { import c.universe._ def makeImpl[ E, R0: c.W...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2020-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2020-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
<|fim_suffix|>uble`. */ implicit val chunkCanBuildFromDouble: ChunkCanBuildFrom[Double] = new ChunkCanBuildFrom[Double] { def apply(from: Chunk[Any]): ChunkBuilder[Double] = new ChunkBuilder.Double def apply(): ChunkBuilder[Double] = new ChunkBuilder.Double } /** * The ins...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2020-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.<|fim_s...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2018-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
package zio.internal import scala.collection.mutable trait MutableSetCompat[V] extends mutable.Set[V] { override def +=(element: V): this.type = { add(element) this } override def -=(element: V): this.type = { remove(element) this } } <|endoftext|>
fim
zio/zio
scala
<|fim_suffix|>ap } def newImmutableTreeSet[A](set: SortedSet[A])(implicit ord: Ordering[A]): immutable.TreeSet[A] = immutable.TreeSet.empty[A] ++ set } <|fim_prefix|>package zio.stm import scala.collection.{mutable, SortedSet, immutable} private object ZSTMUtils { def newMutableMap[K, V](expectedNumEleme...
fim
zio/zio
scala
<|fim_suffix|>OUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package zio import zio.stacktracer.TracingImplicits.disableAutoTrace import scala.collection.IterableOps private[zio] trait ...
fim
zio/zio
scala
<|fim_suffix|> = new ArrayBuilder.ofFloat override def addAll(as: IterableOnce[SFloat]): this.type = { arrayBuilder.addAll(as) this } def addOne(a: SFloat): this.type = { arrayBuilder.addOne(a) this } def clear(): Unit = arrayBuilder.clear() override def equal...
fim
zio/zio
scala
/* * Copyright 2020-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless requir...
fim
zio/zio
scala
<|fim_suffix|> = chunks.iterator var n = total while (it.hasNext) { val chunk = it.next() n -= chunk.length chunk.toArray(n, dest) } Chunk.fromArray(dest) } } /** * Flattens a chunk of chunks into a single chunk by concate...
fim
zio/zio
scala
<|fim_prefix|>package zio.inter<|fim_suffix|> remove(element) this } } <|fim_middle|>nal import scala.collection.mutable trait MutableSetCompat[V] extends mutable.Set[V] { override def addOne(element: V): this.type = { add(element) this } override def subtractOne(element: V): this.type = {<...
fim
zio/zio
scala
<|fim_prefix|>package zio.stm import scal<|fim_suffix|>{ def newMutableMap[K, V](expectedNumElements: Int): mutable.HashMap[K, V] = { val size = if (expectedNumElements <= 3) 4 else Math.ceil(expectedNumElements / 0.75d).toInt new mutable.HashMap[K, V](size, 0.75d) } @inline def newImmutableTreeSet[A](...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2019-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the Licens<|fim_suffix|>under the License is distributed on an "AS IS" BA...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2019-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
/* * Copyright 2017-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless requir...
fim
zio/zio
scala
<|fim_suffix|>o.Scope. Please add a context bound ${rName}: HasNoScope." ) } else { '{ HasNoScope.instance.asInstanceOf[HasNoScope[R]] } } } } <|fim_prefix|>package zio import scala.quoted._ private[zio] abstract class HasNoScopeCompanionVersionSpecific { val instance: HasNoScope[Any] fina...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2021-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
<|fim_prefix|>/* * Copyright 2017-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * *...
fim
zio/zio
scala
<|fim_suffix|>tpe.typeSymbol.isTypeParam || tpe.typeSymbol.isAbstractType then '{ Tag[A] } else findIntersectionInCovariantPosition(tpe).fold('{ Tag[A] })(intersectionFound) } } <|fim_prefix|>package zio import scala.quoted.* private[zio] transparent trait TagVersionSpecific { inline def derived[A]: Tag[A] = ...
fim
zio/zio
scala
<|fim_suffix|> def unsafely[A](f: Unsafe ?=> A): A = f(using Unsafe) implicit def implicitFunctionIsFunction[A](f: Unsafe ?=> A): Unsafe => A = _ => f(using Unsafe) } <|fim_prefix|>/* * Copyright 2021-2024 John A. De Goes and the ZIO Contributors * * Licensed under the Apache License, Version 2.0 (the "L...
fim
zio/zio
scala
<|fim_prefix|>package zio impo<|fim_suffix|>pecificMacros(val ctx: Quotes) { given Quotes = ctx import ctx.reflect._ def validate[Provided: Type, Required: Type, E: Type, A: Type](zio: Expr[ZIO[Required, E, A]]) = { val required = flattenAnd(TypeRepr.of[Required]) val provided = flattenAnd(TypeRepr.of[...
fim
zio/zio
scala
package zio import zio.ZIO.Async import zio.stacktracer.TracingImplicits.disableAutoTrace import java.io.IOException import java.util.concurrent.atomic.AtomicReference import scala.annotation.targetName private[zio] transparent trait ZIOCompanionVersionSpecific { /** * Converts an asynchronous, callback-style ...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.internal.macros.LayerMacros private[zio] transparent trait ZIOVersionSpecific[-R, +E, +A] { self: ZIO[R, E, A] => /** * Splits the environment into two parts, assembling one part using the * speci<|fim_suffix|> def provide[E1 >: E](inline layer: ZLayer[_, E1, _]*): ZIO[An...
fim
zio/zio
scala
<|fim_suffix|> assembles a layer for the provided type `R`, leaving a * remainder `R0`. * * {{{ * val carLayer: ZLayer[Engine with Wheels, Nothing, Car] = ??? * val wheelsLayer: ZLayer[Any, Nothing, Wheels] = ??? * * val layer = ZLayer.makeSome[Engine, Car](carLayer, wheelsLayer) * }}} */ d...
fim
zio/zio
scala
<|fim_suffix|>typeOfOutput Unit): ZIO[Any, E1, Unit] = ${ LayerMacros.runWithImpl[R, E1]('{ self.asInstanceOf[ZLayer[R, E, Unit]] }, 'layer) } } <|fim_prefix|>package zio import zio.internal.macros.LayerMacros private[zio] transparent trait ZLayerVersionSpecific[-R, +E, +A] { self: ZLayer[R, E, A] => inline def...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal.macros import zio._ import scala.quoted._ import scala.compiletime._ import zio.internal.ansi.AnsiStringOps import zio.internal.macros.StringUtils.StringOps import zio.internal.stacktracer.Tracer private[zio] object LayerMacroUtils { type LayerExpr[E] = Expr[ZLayer[_, E, _]] de...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal.macros import zio.internal.ansi.AnsiStringOps import zio._ import scala.quoted._ import scala.compiletime._ import zio.internal.macros.StringUtils.StringOps import java.nio.charset.StandardCharsets import java.util.Base64 import LayerMacroUtils._ object LayerMacros { def construc...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal.macros import zio._ import scala.quoted._ import zio.internal.macros.StringUtils.StringOps import zio.internal.ansi.AnsiStringOps object ZLayerDerivationMacros { transparent inline def deriveLayer[A]: ZLayer[Nothing, Any, A] = ${ deriveLayerImpl[A] } def deriveLayerImpl[A: Typ...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal import zio.ZIOBaseSpec import zio.test.Assertion._ import zio.test._ object OneShotSpec extends ZIOBaseSpec { def spec = suite("OneShotSpec")( suite("Make a new OneShot")( test("se<|fim_suffix|>rt(oneShot.get())(equalTo(1)) }, test("set must not accept a nul...
fim
zio/zio
scala
<|fim_suffix|>ise") { lazy val someValue: JSPromise[String] = JSPromise.resolve[String](null) assertZIO(ZIO.fromPromiseJS(someValue).map(Option(_)))(isNone) } ), suite("ZIO.fromPromiseJS must")( test("be lazy on the Promise parameter") { var evaluated = false ...
fim
zio/zio
scala
<|fim_suffix|>mplicit unsafe => runtime.unsafe.run { right.take.zipWith(right.take) { (first, last) => p3 = first p4 = last } }.getOrThrowFiberFailure() } @Arbiter def arbiter(r: IIII_Result): Unit = { r.r1 = p1 r.r2 = p2 r.r3 ...
fim
zio/zio
scala
<|fim_suffix|>un = for { latch <- Promise.make[Nothing, Unit] frk = (latch.succeed(()) *> ZIO.never).provideLayer(DefaultJvmMetrics.liveV2.unit) _ <- frk.forkDaemon.flatMap(f => latch.await *> f.interrupt *> f.await) } yield () run *> assertComplet...
fim
zio/zio
scala
package zio import zio.SerializableSpecHelpers._ import zio.test.Assertion._ import zio.test.TestAspect._ import zio.test.{test => testSync, _} import java.io.{ByteArrayInputStream, ByteArrayOutputStream, ObjectInputStream, ObjectOutputStream} object SerializableSpec extends ZIOBaseSpec { def spec = suite("Serial...
fim
zio/zio
scala
<|fim_prefix|>package zio.autowire import zio._ import zio.test._ import zio.test.Assertion._ object LargeAutoWireSpec extends ZIOBaseSpec { case class V0( v13: V13, v14: V14, v10: V10, v7: V7, v23: V23, v27: V27 ) object V0 { val layer = ZLayer.derive[V0] } case class V1( v3...
fim
zio/zio
scala
package zio.internal import org.openjdk.jcstress.annotations._ import org.openjdk.jcstress.infra.results.I_Result object BoundedHubArbConcurrencyTests { /* * Tests that there are no race conditions between publishing and unsubscribing. */ @JCStressTest @Outcome.Outcomes( Array( new Outcome(id =...
fim
zio/zio
scala
<|fim_suffix|>l subscription = hub.subscribe() hub.publish(2) r.r1 = subscription.poll(-1) } } /* * Tests that there are no race conditions between polling and unsubscribing. */ @JCStressTest @Outcome.Outcomes( Array( new Outcome(id = Array("-1"), expect = Expect.ACCEPTABLE), ...
fim
zio/zio
scala
<|fim_suffix|>ribe() hub.publish(2) r.r1 = subscription.poll(-1) } } } <|fim_prefix|>package zio.internal import org.openjdk.jcstress.annotations._ import org.openjdk.jcstress.infra.results.I_Result object BoundedHubSingleConcurrencyTests { /* * Tests that there are no race conditions between ...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal import zio.ZIOBaseSpec import zio.test.Assertion.equalTo import zio.test._ object ConcurrentWeakHashSetSpecJVM extends ZIOBaseSpec { final case class Wrapper[A](value: A) { override def toString: String = value.toString } def spec = suite("ConcurrentWeakHashSetSpec")( ...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal import zio.SerializableSpecHelpers._ import zio.ZIOBaseSpec import zio.te<|fim_suffix|> }, test("an arbitrary capacity ring buffer") { val q = MutableConcurrentQueue.bounded[Int](2) q.offer(1) val returnQ = serializeAndDeserialize(q) returnQ.offe...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal import org.openjdk.jcstress.annotations._ import org.openjdk.jcstress.infra.results.{IIII_Result, II_Result, I_Result} object OneElementConcurrentQueueConcurrencyTests { /* * Tests that offer writes are atomic (simple case, doesn't consider * concurrent polls) */ @JCStr...
fim
zio/zio
scala
<|fim_suffix|>ect = Expect.ACCEPTABLE), new Outcome(id = Array("3, 1, 2, 4"), expect = Expect.ACCEPTABLE) ) ) @State class OfferAllTest { val q: RingBufferArb[Int] = RingBufferArb(4) @Actor def actor1(): Unit = { q.offerAll(List(1, 2)) () } @Actor def actor2(): Unit...
fim
zio/zio
scala
package zio.internal import org.openjdk.jcstress.annotations._ import org.openjdk.jcstress.infra.results.{IIIIII_Result, IIII_Result, II_Result} object RingBufferPow2ConcurrencyTests { /* * Tests that [[RingBufferPow2.offer]] is atomic. */ @JCStressTest @Outcome.Outcomes( Array( new Outcome(id =...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal import org.openjdk.jcstress.annotations._ import org.openjdk.jcstress.infra.results.I_Result object UnboundedHubConcurrencyTests { /* * Tests that there are no race conditions between publishing and unsubscribing. */ @JCStressTest @Outcome.Outcomes( Array( new...
fim
zio/zio
scala
<|fim_suffix|> } var r1: List[Int] = null var r2: List[Int] = null @Actor def actor1(): Unit = { r1 = map.reverseIterator.map(_._2).toList () } @Actor def actor2(): Unit = { r2 = map.reverseIterator.map(_._2).toList () } @Arbiter def arbiter(r: LL_R...
fim
zio/zio
scala
package zio package interop import zio.test.Assertion._ import zio.test._ import java.net.InetSocketAddress import java.nio.ByteBuffer import java.nio.channels.{AsynchronousServerSocketChannel, AsynchronousSocketChannel} object JavaSpecJVM extends ZIOBaseSpec { import ZIOTag._ def spec: Spec[Any, Any] = suite(...
fim
zio/zio
scala
<|fim_suffix|>me.unsafe.run(TSemaphore.makeCommit(1L)).getOrThrowFiberFailure()) var fiber: Fiber[Nothing, Unit] = null.asInstanceOf[Fiber[Nothing, Unit]] @Actor def actor1(): Unit = Unsafe.unsafe { implicit unsafe => val zio = ZIO.scoped(semaphore.withPermitScoped) fiber = runtime.un...
fim
zio/zio
scala
<|fim_prefix|>package zio.stm import zio._ import zio.test<|fim_suffix|>ZSTM.suspend { i += 1 arr.update(i, v + _) } ) } } for { arr <- TArray.make(List.fill(1000)("foo"): _*).commit stm = transaction(arr) _ <-...
fim
zio/zio
scala
package zio import zio.test.Assertion._ import zio.test.TestAspect.nonFlaky import zio.test._ import java.util.concurrent.atomic.{AtomicBoolean, AtomicInteger} object BlockingSpec extends ZIOBaseSpec { def spec = suite("BlockingSpec")( suite("attemptBlocking")( test("completes successfully") { ...
fim
zio/zio
scala
<|fim_suffix|> ZIO .runtime[Any] .map(runtime => Unsafe.unsafe(implicit unsafe => runtime.unsafe.run(tst.onExecutor(executor)).getOrThrowFiberFailure()) ) } @@ nonFlaky ) @@ zioTag(future) } <|fim_prefix|>package zio import zio.test.Assertion._ import zio.test.TestA...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion._ import zio.test.TestAspect._ import zio.test._ import java.time.Instant import java.util.concurrent.TimeUnit object ClockSpecJVM extends ZIOBaseSpec { def spec = suite("ClockSpec")( test("currentTime has microsecond resolution on JRE >= 9") { ...
fim
zio/zio
scala
<|fim_suffix|> handle.set(update2) val v2 = handle.get() handle.remove() val v3 = handle.get() resRef.set((v1, v2, v3)) } ...
fim
zio/zio
scala
<|fim_suffix|> .repeatUntil(_ >= 1) <* f.interrupt } yield c assertZIO(Live.live(zio))(isGreaterThanEqualTo(1)) } @@ zioTag(interruption, regression) ) } <|fim_prefix|>package zio import zio.test.Assertion._ import zio.test.TestAspect.{nonFlaky, silent} import zio.test._ import java.util.c...
fim
zio/zio
scala
<|fim_suffix|> val f1 = ZIO.succeed { while (loop.get()) { Thread.sleep(1) } } val f2 = ZIO.succeed { loop.set(false) } (f1, f2) } } <|fim_prefix|>package zio import zio.test.{TestAspect, assertCompletes} import java.util.concurrent.atomic.AtomicBoolean object RuntimeSpec extends ZIO...
fim
zio/zio
scala
<|fim_suffix|> _ <- threadExited.await r <- ZIO.succeed(threadWasBlockedUntilFinalizationDone.get()) } yield assertTrue(r) } @@ TestAspect.timeout(10.seconds) @@ TestAspect.nonFlaky(5) ) } <|fim_prefix|>package zio import zio.test._ import java.util.concurrent.CountDownLatch import j...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion._ import zio.test._ import java.io.File object SystemSpec extends ZIOBaseSpec { def spec: Spec[Any, Any] = suite("SystemSpec")( suite("Fetch an environment variable and check that")( test("If it exists, return a reasonable value") { assertZIO(l...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion.isNull import zio.test.TestAspect.{blocking, nonFlaky, sequential, withLiveClock} import zio.test._ import java.util.concurrent.atomic.AtomicBoolean object ZIOSpecJVM extends ZIOBaseSpec { def spec = suite("ZIOSpecJVM")( suite("cooperative yielding") { ...
fim
zio/zio
scala
<|fim_suffix|>t.make[Int] new Thread(() => { Thread.sleep(10L) oneShot.set(1) }).start() assert(oneShot.tryGet(20L))(equalTo(1)) }, test("returns null if the value is not set within the timeout") { val oneShot = OneShot.make[Object] ...
fim
zio/zio
scala
<|fim_prefix|>package zio.internal import zio._ import zio.test.Assertion._ import zio.test._ object SingleThreadedRingBufferSpec extends ZIOBaseSpec { def spec = suite("SingleThreadedRingBufferSpec")( <|fim_suffix|>t(actual)(equalTo(expected)) } } ) } <|fim_middle|> test("use SingleThre...
fim
zio/zio
scala
<|fim_prefix|>package zio package interop import zio.interop.javaz._ import zio.test.Assertion._ import zio.test._ import java.util.concurrent.{CompletableFuture, CompletionStage, Future} import java.util.function.BiFunction object JavaSpec extends ZIOBaseSpec { import ZIOTag._ def spec: Spec[Any, Any] = suite...
fim
zio/zio
scala
package zio import zio.test._ /** * Tests exposing the bug in BitChunk.apply() where minBitIndex was not * accounted for. * * The bug: BitChunk.apply(n) used 'n' directly instead of (n + minBitIndex). * After drop(), minBitIndex > 0, so apply(0) returned the wrong bit. * * These tests FAIL with buggy code and ...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion._ import zio.test._ object BitChunkByteSpec extends ZIOBaseSpec { val genByteChunk: Gen[Any, Chunk[Byte]] = for { bytes <- Gen.listOf(Gen.byte) } yield Chunk.fromIterable(bytes) val genInt: Gen[Any, Int] = Gen.small(Gen.const(_)) val genBi...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion._ import zio.test._ object BitChunkIntSpec extends ZIOBaseSpec { val genIntChunk: Gen[Any, Chunk[Int]] = for { ints <- Gen.listOf(Gen.int) } yield Chunk.fromIterable(ints) val genInt: Gen[Any, Int] = Gen.small(Gen.const(_)) val genEndianne...
fim
zio/zio
scala
<|fim_suffix|>(endianness)).mkString.take(n).take(m) assert(actual)(equalTo(expected)) } }, test("slice") { check(genLongChunk, genInt, genInt, genEndianness) { (bytes, n, m, endianness) => val actual = bytes.asBitsLong(endianness).slice(n, m).toBinaryString val expected = ...
fim
zio/zio
scala
<|fim_prefix|>package zio object AcquireReleaseWithTypeInferenceSpec { class A class B class R1 class R2 class R3 class E class E1 extends E class E2 ext<|fim_suffix|>cquireReleaseWith(acquire)(release)(use) } } <|fim_middle|>ends E def infersRType3: ZIO[R1 with R2 with R3, E, B] = { val acqui...
fim
zio/zio
scala
<|fim_suffix|> for { ref <- Ref.make[Either[String, Int]](Right(0)) cached <- Cached.auto(ref.get.absolve, Schedule.spaced(1.second)) value1 <- cached.get value2 <- ref.set(Left("Uh oh!")) *> TestClock.adjust(10.seconds) *> cached.get } yield assertTrue(value1 == 0) && asse...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion._ import zio.test._ object CanFailSpec extends ZIOBaseSpec { def spec = s<|fim_suffix|>n't compile") { val result = typeCheck { """ import zio._ val io = ZIO.attempt("io") val uio = ZIO.succeed("uio") ...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion._ import zio.test.TestAspect._ import zio.test._ import scala.concurrent.Future object CancelableFutureSpec extends ZIOBaseSpec { import ZIOTag._ def roundtrip[R, A](zio: RIO[R, A]): RIO[R, A] = for { future <- zio.toFuture a <- ZIO.fromF...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.Cause.{Both, Die, Empty, Fail, Interrupt, Stackless, Then, empty} import zio.test.Assertion._ import zio.test.TestAspect.samples import zio.test._ import scala.annotation.tailrec object CauseSpec extends ZIOBaseSpec { def spec = suite("CauseSpec")( suite("Cause")( te...
fim
zio/zio
scala
package zio import zio.test.Assertion._ import zio.test._ import java.nio.charset.{Charset, StandardCharsets} object ChunkAsStringSpec extends ZIOBaseSpec { def spec = suite("ChunkAsStringSpec")( test("bytes asString with charset") { check(Gen.alphaNumericString) { str => val chunk = Chunk.fromA...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion.equalTo import zio.test._ import java.nio._ object ChunkBufferSpec extends ZIOBaseSpec { def spec = suite("ChunkBufferSpec")( suite("ByteBuffer")( test("byte array buffer no copying") { ZIO.succeed { val array = Array(1, 2, 3).map(_....
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion._ import zio.test._ object ChunkBuilderSpec extends ZIOBaseSpec { def spec = suite("ChunkBuilderSpec")( suite("Boolean")( test("addOne")( check(Gen.chunkOf(Gen.boolean)) { as => val builder = new ChunkBuilder.Boolean as.forea...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion._ import zio.test._ object ChunkPackedBooleanSpec extends ZIOBaseSpec { val genEndianness: Gen[Any, Chunk.BitChunk.Endianness] = Gen.elements(Chunk.BitChunk.Endianness.BigEndian, Chunk.BitChunk.Endianness.LittleEndian) val genBoolChunk: Gen[Any, Chunk[Bool...
fim
zio/zio
scala
<|fim_suffix|>", "c")) case _ => assertNever("Expected Chunk.AnyRefArray") } }, test("primitives") { Chunk.fromIterable(Array(1, 2, 3)) match { case c: Chunk.IntArray => assertTrue(c == Chunk(1, 2, 3)) case _ => assertN...
fim
zio/zio
scala
<|fim_suffix|>ut a offsetDateTime matching to timezone from java.time.Clock") { val zioEuropeAmsterdamClock = Clock.ClockJava(europeAmsterdamFixedClock) val zioAmericaPhoenixClock = Clock.ClockJava(americaPhoenixFixedClock) assertZIO(ZIO.collectAll(Chunk(zioEuropeAmsterdamClock.currentDateTime, zioAm...
fim
zio/zio
scala
<|fim_suffix|>("nested map args") { val args = Chunk("--mappings.abc=error") for { config <- ConfigProvider.fromAppArgs(ZIOAppArgs(args)).load(Config.table("mappings", Config.string)) } yield assertTrue(config == Map("abc" -> "error")) } + test("boolean args") { val...
fim
zio/zio
scala
<|fim_suffix|>g.string)) } yield assertTrue(config == Map("ABC" -> "ERROR")) } + test("envProvider should replace dashes with underscores") { for { _ <- TestSystem.putEnv("SNAKE_CASE", "TRUE") config <- ConfigProvider.envProvider.load(Config.string("snake-case")) ...
fim
zio/zio
scala
<|fim_suffix|>ult == Nil) } + test("empty list with product with description") { val configProvider = ConfigProvider.fromMap( Map( "departments" -> "<nil>" ) ) val member = Config.int("age").zip(Config.string("name")) val co...
fim
zio/zio
scala
<|fim_suffix|> val sameLength = zio.Config.Secret("some-secrez" * 1000) assertZIO(boxTest(ZIO.attempt(sameLength equals secret), ZIO.attempt(differentLength equals secret)))( equalTo(false) ) }, test("doesn't leak char") { val secret = ...
fim
zio/zio
scala
<|fim_suffix|>) val right = differ.combine(patch1, differ.combine(patch2, patch3)) assertTrue(equal(differ.patch(left)(value1), differ.patch(right)(value1))) } }, test("combining a patch with an empty patch is an identity") { check(gen, gen) { (oldValue, newValue) => ...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion.{equalTo, not} import zio.test.assert import ja<|fim_suffix|>.milli = fromNanos(1000000L)") { assert(1L.milli)(equalTo(Duration.fromNanos(1000000L))) }, test("2L.millis = fromNanos(2000000L)") { assert(2L.millis)(equalTo(Durat...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion._ import zio.test._ import java.util.concurrent.RejectedExecutionException import scala.concurrent.ExecutionContext final class TestExecutor(val submitResult: Boolean) extends Executor { val here: Boolean = true de...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.test.Assertion._ import zio.test.TestAspect._ import zio.test._ object FiberIdSpec extends ZIOBaseSpec { def spec = suite("FiberIdSpec")( <|fim_suffix|> }, test("toSet") { assert(fiberId.toSet.size)(equalTo(20000)) } ) @@ sequential @@ jvmOnly ) v...
fim
zio/zio
scala
<|fim_prefix|>package zio import zio.FiberRefSpecUtil._ import zio.test.Assertion._ import zio.test.TestAspect.{exceptJS, nonFlaky} import zio.test._ object FiberRefSpec extends ZIOBaseSpec { import ZIOTag._ def spec = suite("FiberRefSpec")( suite("Classic FiberRef.make")( test("fork can modify ref va...
fim
zio/zio
scala