Skip to content

Commit

Permalink
test: acceptance test for _vectorizedFloat
Browse files Browse the repository at this point in the history
Bool literals were not included in the vec repeat test since they are
still not eligible for vectorization. Ref: #4997
  • Loading branch information
Owen Nelson committed Aug 16, 2022
1 parent c658077 commit 254e14f
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions stdlib/universe/map_vectorize_float_test.flux
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 254e14f

Please sign in to comment.