From ae7664597ed15f9ac779a9bac0595ab4125457c4 Mon Sep 17 00:00:00 2001 From: Lars Müller <34514239+appgurueu@users.noreply.github.com> Date: Wed, 4 May 2022 13:44:14 +0200 Subject: Add vector.combine (#11920) --- builtin/common/tests/vector_spec.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'builtin/common/tests/vector_spec.lua') diff --git a/builtin/common/tests/vector_spec.lua b/builtin/common/tests/vector_spec.lua index 25880236b..6a0b81a89 100644 --- a/builtin/common/tests/vector_spec.lua +++ b/builtin/common/tests/vector_spec.lua @@ -128,6 +128,14 @@ describe("vector", function() assert.equal(vector.new(4.1, 5.9, 5.5), a:apply(f)) end) + it("combine()", function() + local a = vector.new(1, 2, 3) + local b = vector.new(3, 2, 1) + assert.equal(vector.add(a, b), vector.combine(a, b, function(x, y) return x + y end)) + assert.equal(vector.new(3, 2, 3), vector.combine(a, b, math.max)) + assert.equal(vector.new(1, 2, 1), vector.combine(a, b, math.min)) + end) + it("equals()", function() local function assertE(a, b) assert.is_true(vector.equals(a, b)) -- cgit v1.2.3