local W=require("\064\068\101\118\080\097\099\107\097\103\101\115\047\074\101\115\116\071\108\111\098\097\108\115")local z=W.describe local g=W.test local Q=W.expect local s=require("\046\046\047\105\110\105\116")local t=s.Future z("\097\119\097\105\116",function()g("\105\109\109\101\100\105\097\116\101",function()local W=t.new(function()return"\097","\098","\099"end)local z=W:await();(Q(z:isOk())).toBe(true)local g={z:unwrapOk()};(Q(g)).toEqual({"\097";"\098";"\099"})end)g("\121\105\101\108\100\105\110\103",function()local W=t.new(function()wait()return"\097","\098","\099"end)local z=W:await();(Q(z:isOk())).toBe(true)local g={z:unwrapOk()};(Q(g)).toEqual({"\097","\098";"\099"})end)end)
local JestGlobals = require("@DevPackages/JestGlobals")

local describe = JestGlobals.describe
local test = JestGlobals.test
local expect = JestGlobals.expect

local Futures = require("../init")
local Future = Futures.Future

describe("await", function()
	test("immediate", function()
		local myFuture = Future.new(function()
			return "a", "b", "c"
		end)

		local result = myFuture:await()
		expect(result:isOk()).toBe(true)

		local values = { result:unwrapOk() }

		expect(values).toEqual({ "a", "b", "c" })
	end)

	test("yielding", function()
		local myFuture = Future.new(function()
			wait()
			return "a", "b", "c"
		end)

		local result = myFuture:await()
		expect(result:isOk()).toBe(true)

		local values = { result:unwrapOk() }

		expect(values).toEqual({ "a", "b", "c" })
	end)
end)
