Reformat badly formatted btest

This commit is contained in:
Evan Typanski 2025-01-09 17:43:12 -05:00
parent 06061a3579
commit 7a6f7baf4a

View file

@ -7,11 +7,10 @@ function test_case(msg: string, expect: bool)
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL"); print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
} }
# Note: only global sets can be initialized with curly braces # Note: only global sets can be initialized with curly braces
global sg1: set[string] = { "curly", "braces" }; global sg1: set[string] = { "curly", "braces" };
global sg2: set[port, string, bool] = { [10/udp, "curly", F], global sg2: set[port, string, bool] = { [ 10/udp, "curly", F ], [ 11/udp,
[11/udp, "braces", T] }; "braces", T ] };
global sg3 = { "more", "curly", "braces" }; global sg3 = { "more", "curly", "braces" };
function basic_functionality() function basic_functionality()
@ -20,8 +19,8 @@ function basic_functionality()
local s2: set[string] = set(); local s2: set[string] = set();
local s3: set[string]; local s3: set[string];
local s4 = set("type inference"); local s4 = set("type inference");
local s5: set[port, string, bool] = set( [1/tcp, "test", T], local s5: set[port, string, bool] = set([ 1/tcp, "test", T ], [ 2/tcp,
[2/tcp, "example", F] ); "example", F ]);
local s6: set[port, string, bool] = set(); local s6: set[port, string, bool] = set();
local s7: set[port, string, bool]; local s7: set[port, string, bool];
local s8 = set([ 8/tcp, "type inference", T ]); local s8 = set([ 8/tcp, "type inference", T ]);
@ -138,7 +137,6 @@ function basic_functionality()
test_case("remove element", |sg3| == 3); test_case("remove element", |sg3| == 3);
test_case("!in operator", "curly" !in sg3); test_case("!in operator", "curly" !in sg3);
local a = set(1, 5, 7, 9, 8, 14); local a = set(1, 5, 7, 9, 8, 14);
local b = set(1, 7, 9, 2); local b = set(1, 7, 9, 2);
@ -208,7 +206,8 @@ function complex_index_type_table()
# Iteration # Iteration
for ( ti in s ) for ( ti in s )
{ {
test_case( "table index iteration", to_json(ti) == to_json(table(["k2"] = "v2")) ); test_case("table index iteration", to_json(ti) == to_json(table([ "k2" ] =
"v2")));
break; break;
} }
@ -235,7 +234,8 @@ function complex_index_type_vector()
for ( vi in s ) for ( vi in s )
{ {
test_case( "vector index iteration", to_json(vi) == to_json(vector("v3", "v4")) ); test_case("vector index iteration", to_json(vi) == to_json(vector("v3",
"v4")));
break; break;
} }
@ -291,7 +291,8 @@ function complex_index_type_pattern()
local fjr = from_json(to_json(s), p_set); local fjr = from_json(to_json(s), p_set);
test_case("pattern index JSON roundtrip success", fjr$valid); test_case("pattern index JSON roundtrip success", fjr$valid);
test_case( "pattern index JSON roundtrip correct", to_json(s) == to_json(fjr$v) ); test_case("pattern index JSON roundtrip correct", to_json(s) == to_json(
fjr$v));
} }
# Issue 3933: Sets defined with an empty container and {[]} were silently discarding # Issue 3933: Sets defined with an empty container and {[]} were silently discarding