Skip to content

Commit

Permalink
ex a completed
Browse files Browse the repository at this point in the history
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
  • Loading branch information
ivankatliarchuk committed Aug 29, 2023
1 parent f52f56b commit 572358d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 44 deletions.
20 changes: 17 additions & 3 deletions playground/opa-by-example/a__rules/ex1/exercices.rego
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import future.keywords
# Input: {"a": true, "b": true, "c": true}
# Output: {"output1": true, ...}
output1 := true if {
false # TODO
# print(input)
some el in input
el == true
# v if "hello" == "world"
# print(sum(result))
}

# Exercise 2
Expand All @@ -31,7 +35,8 @@ output1 := true if {
# Input: {"a": false, "b": false, "c": true}
# Output: {"output2": true, ...}
output2 := true if {
false # TODO
some el in input
el == true
}

# Exercise 3
Expand All @@ -42,5 +47,14 @@ output2 := true if {
# Input: {"a": true, "b": false, "c": true}
# Output: {"output3": true, ...}
output3 := true if {
false # TODO
input.a == true
input.c == true
}

# METADATA
# title: all true custom function
all_true(elements) := false if {
print(elements)
some el in elements
el != true
}
83 changes: 42 additions & 41 deletions playground/opa-by-example/a__rules/ex1/tests.rego
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,45 @@ test_A_0_exercise1_all_true if {
not _test_enabled
}

# test_A_0_exercise1_two_true if {
# test_input := {"a": true, "b": true, "c": false}
# not output1 with input as test_input
# } else {
# not _test_enabled
# }

# test_A_0_exercise2_none_true if {
# test_input := {"a": false, "b": false, "c": false}
# not output2 with input as test_input
# } else {
# not _test_enabled
# }

# test_A_0_exercise2_one_true if {
# test_input := {"a": false, "b": false, "c": true}
# util.return_unchanged(output2) == true with input as test_input
# } else {
# not _test_enabled
# }

# test_A_0_exercise3_a_c if {
# test_input := {"a": true, "b": false, "c": true}
# util.return_unchanged(output3) == true with input as test_input
# } else {
# not _test_enabled
# }

# test_A_0_exercise3_b_c if {
# test_input := {"a": false, "b": true, "c": true}
# not output3 with input as test_input
# } else {
# not _test_enabled
# }

# test_A_0_exercise3_a if {
# test_input := {"a": true, "b": false, "c": false}
# not output3 with input as test_input
# } else {
# not _test_enabled
# }
test_A_0_exercise1_two_true if {
test_input := {"a": true, "b": true, "c": false}
output1 with input as test_input
} else {
not _test_enabled
}


test_A_0_exercise2_none_true if {
test_input := {"a": false, "b": false, "c": false}
not output2 with input as test_input
} else {
not _test_enabled
}

test_A_0_exercise2_one_true if {
test_input := {"a": false, "b": false, "c": true}
util.return_unchanged(output2) == true with input as test_input
} else {
not _test_enabled
}

test_A_0_exercise3_a_c if {
test_input := {"a": true, "b": false, "c": true}
util.return_unchanged(output3) == true with input as test_input
} else {
not _test_enabled
}

test_A_0_exercise3_b_c if {
test_input := {"a": false, "b": true, "c": true}
not output3 with input as test_input
} else {
not _test_enabled
}

test_A_0_exercise3_a if {
test_input := {"a": true, "b": false, "c": false}
not output3 with input as test_input
} else {
not _test_enabled
}

0 comments on commit 572358d

Please sign in to comment.