test case for vector coercions, including holes

This commit is contained in:
Vern Paxson 2021-09-02 13:00:59 -07:00
parent 38578a2ea3
commit 9757d37332
2 changed files with 45 additions and 0 deletions

View file

@ -0,0 +1,4 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[5.5, 5.2, -3.9, 20.0]
[11, 5, , 107, , , 1046]
[-2, -4, , -7, , -18, -999]

View file

@ -0,0 +1,41 @@
# @TEST-EXEC: zeek -b %INPUT >output 2>&1
# @TEST-EXEC: btest-diff output
event zeek_init()
{
local a = vector(3.5, 1.2, -9.9, 12);
local b = vector(2, 4, 6, 8);
local c: vector of double;
# The following requires correctly coercing 'b' to a vector-of-double
# prior to doing the addition.
c = a + b;
print c;
}
event zeek_init()
{
local v1 = vector(2,4);
local v2 = vector(9,1);
# Give both v1 and v2 a hole at index 2.
v1[3] = 7;
v2[3] = 100;
# Give v1 a hole at 4 and v2 a hole at 5.
v1[5] = 18;
v1[6] = 999;
v2[4] = 42;
v2[6] = 47;
print v1 + v2;
# Make sure that holes get relected in unary operations,
# and also that vectors of count are properly coerced to
# vectors of int.
local v3: vector of int;
v3 = -v1;
print v3;
}