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("\106\111\105\110",function()g("\111\107",function()local W=t.new(function()return"\097","\098","\099"end)local z=W:join(t.new(function()return"\100","\101","\102"end))local g=z:await();(Q(g:isOk())).toBe(true)local s=g:unwrapOk();(Q(s)).toEqual({"\097","\098";"\099";"\100","\101";"\102"})end)g("\101\114\114",function()local W=t.new(function()error("\065",0)end)local z=W:join(t.new(function()error("\066",0)end))local g=z:await();(Q(g:isOk())).toBe(true)local s=g:unwrapErr();(Q(s[1]:unwrapErr())).toEqual("\065");(Q(s[2]:unwrapErr())).toEqual("\066")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("join", function()
	test("ok", function()
		local myFuture = Future.new(function()
			return "a", "b", "c"
		end)

		local nextFuture = myFuture:join(Future.new(function()
			return "d", "e", "f"
		end))

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

		local values = result:unwrapOk()

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

	test("err", function()
		local myFuture = Future.new(function()
			error("A", 0)
		end)

		local nextFuture = myFuture:join(Future.new(function()
			error("B", 0)
		end))

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

		local values = result:unwrapErr()

		expect(values[1]:unwrapErr()).toEqual("A")
		expect(values[2]:unwrapErr()).toEqual("B")
	end)
end)
