feat: implement case function (#16)

Follow GitHub Actions

* added unit tests

Closes #15

Reviewed-on: https://gitea.com/actions-oss/act-cli/pulls/16
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-committed-by: ChristopherHX <christopher.homberger@web.de>
This commit is contained in:
ChristopherHX
2025-12-18 19:27:30 +00:00
committed by ChristopherHX
parent 83cbf1f2b8
commit ee2e0135d5
6 changed files with 164 additions and 14 deletions

View File

@@ -97,6 +97,12 @@ func TestEvaluator_Raw(t *testing.T) {
{"contains(fromjson('[[3,5],[5,6]]').*[1], 6)", true},
{"contains(fromjson('[[3,5],[5,6]]').*[1], 3)", false},
{"contains(fromjson('[[3,5],[5,6]]').*[1], '6')", true},
{"case(6 == 6, 0, 1)", 0.0},
{"case(6 != 6, 0, 1)", 1.0},
{"case(6 != 6, 0, 'test')", "test"},
{"case(contains(fromjson('[\"ac\"]'), 'a'), 0, 'test')", "test"},
{"case(0 == 1, 0, 2 == 2, 1, 0)", 1.0},
{"case(0 == 1, 0, 2 != 2, 1, 0)", 0.0},
}
for _, tt := range tests {