From 254e14f7560e49c1f1945a596d7ae7335d883e03 Mon Sep 17 00:00:00 2001 From: Owen Nelson Date: Thu, 11 Aug 2022 16:12:46 -0700 Subject: [PATCH] test: acceptance test for _vectorizedFloat Bool literals were not included in the vec repeat test since they are still not eligible for vectorization. Ref: #4997 --- stdlib/universe/map_vectorize_float_test.flux | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 stdlib/universe/map_vectorize_float_test.flux diff --git a/stdlib/universe/map_vectorize_float_test.flux b/stdlib/universe/map_vectorize_float_test.flux new file mode 100644 index 0000000000..36966e5709 --- /dev/null +++ b/stdlib/universe/map_vectorize_float_test.flux @@ -0,0 +1,71 @@ +package universe_test + + +import "array" +import "testing" + +testcase vec_with_float { + want = + array.from( + rows: [ + { + // float + f1: 123.0, + f2: 123.0, + // int + i1: 456, + i2: 456.0, + // uint + u1: uint(v: 789), + u2: 789.0, + // string + s1: "1011.12", + s2: 1011.12, + // bool false + b1F: false, + b2F: 0.0, + // bool true + b1T: true, + b2T: 1.0, + }, + ], + ) + + got = + array.from( + rows: [ + { + f1: 123.0, + i1: 456, + u1: uint(v: 789), + s1: "1011.12", + b1F: false, + b1T: true, + }, + ], + ) + |> map( + fn: (r) => + ({r with + f2: float(v: r.f1), + i2: float(v: r.i1), + u2: float(v: r.u1), + s2: float(v: r.s1), + b2F: float(v: r.b1F), + b2T: float(v: r.b1T), + }), + ) + + testing.diff(want, got) +} + +// FIXME: add bool literals to this once they are enabled in #4997 +testcase vec_with_float_const { + want = array.from(rows: [{x: 1, f: 123.456, i: 123.0}]) + + got = + array.from(rows: [{x: 1}]) + |> map(fn: (r) => ({r with f: float(v: 123.456), i: float(v: 123)})) + + testing.diff(want, got) +}