@@ -7,7 +7,10 @@ describe("detect contradictory categorical if clauses", {
77 if (a == " a" ) b == " b2"
88 )
99
10- a <- detect_contradicting_if_rules(v )
10+ expect_output_file(
11+ a <- detect_contradicting_if_rules(v , verbose = TRUE ),
12+ file = " detect_contradicting_if_rules.txt"
13+ )
1114 expect_equal(a , list (" a == \" a\" " = c(" V1" , " V2" )))
1215 })
1316
@@ -17,7 +20,7 @@ describe("detect contradictory categorical if clauses", {
1720 if (a == " a" ) x < - 1
1821 )
1922
20- a <- detect_contradicting_if_rules(v )
23+ a <- detect_contradicting_if_rules(v , verbose = FALSE )
2124 expect_equal(a , list (" a == \" a\" " = c(" V2" , " V1" )))
2225 })
2326
@@ -27,7 +30,7 @@ describe("detect contradictory categorical if clauses", {
2730 if (x > 0 ) b == " b2"
2831 )
2932
30- a <- detect_contradicting_if_rules(v )
33+ a <- detect_contradicting_if_rules(v , verbose = FALSE )
3134 expect_equal(a , list (" x > 0" = c(" V2" , " V1" )))
3235 })
3336
@@ -37,8 +40,28 @@ describe("detect contradictory categorical if clauses", {
3740 if (x > 0 ) y < 0
3841 )
3942
40- a <- detect_if_clauses( v )
43+ a <- detect_contradicting_if_rules( v , verbose = FALSE )
4144 expect_equal(a , list (" x > 0" = c(" V2" , " V1" )))
4245 })
4346
47+ it(" detects conflicting chains" , {
48+ v <- validator(
49+ if (income > 0 ) job == " yes" ,
50+ if (job == " yes" ) income == 0
51+ )
52+
53+ a <- detect_contradicting_if_rules(v , verbose = FALSE )
54+ expect_equal(a , list (" income > 0" = c(" V2" , " V1" )))
55+ })
56+
57+ it(" detects multi conditions" , {
58+ v <- validator(
59+ if (nace == " a" && export > 0 ) international == TRUE ,
60+ if (nace == " a" ) international == FALSE
61+ )
62+
63+ a <- detect_contradicting_if_rules(v , verbose = FALSE )
64+ skip(" Need to fix multi conditions" )
65+ })
66+
4467})
0 commit comments