@@ -23,33 +23,35 @@ describe("mods.Set", function()
2323 -- stylua: ignore
2424 local tests = {
2525 ---- ----------fname-------------|--set--|-param-|-expected-|-same_ref?---
26- { " add" , _b_d_ , " c" , _bcd_ , true },
27- { " clear" , abcde , nil , {} , true },
28- { " contains" , abcde , " a" , true , },
29- { " contains" , abcde , " z" , false , },
30- { " copy" , abcde , nil , abcde , },
31- { " difference_update" , a_c_e , _bcd_ , a___e , true },
32- { " difference" , a_c_e , _bcd_ , a___e , },
33- { " intersection_update" , a_c_e , _bcd_ , __c__ , true },
34- { " intersection" , a_c_e , _bcd_ , __c__ , },
35- { " isdisjoint" , _b_d_ , ___de , false , },
36- { " isdisjoint" , _b_d_ , a___e , true , },
37- { " isempty" , _____ , nil , true , },
38- { " isempty" , abcde , nil , false , },
39- { " issubset" , abcd_ , abcde , true , },
40- { " issubset" , abcde , abcd_ , false , },
41- { " issuperset" , abcd_ , abcde , false , },
42- { " issuperset" , abcde , abcd_ , true , },
43- { " len" , _____ , nil , 0 , },
44- { " len" , a_c__ , nil , 2 , },
45- { " map" , abc__ , upper , ABC__ , },
46- { " pop" , _____ , nil , nil , },
47- { " remove" , _bcd_ , " c" , _b_d_ , true },
48- { " symmetric_difference_update" , a_c_e , _bcd_ , ab_de , true },
49- { " symmetric_difference" , a_c_e , _bcd_ , ab_de , },
50- { " union" , abc__ , ___de , abcde , },
51- { " update" , abc__ , ___de , abcde , true },
52- { " values" , _____ , nil , {} , },
26+ { " add" , _b_d_ , " c" , _bcd_ , true },
27+ { " clear" , abcde , nil , {} , true },
28+ { " contains" , abcde , " a" , true , },
29+ { " contains" , abcde , " z" , false , },
30+ { " copy" , abcde , nil , abcde , false },
31+ { " difference_update" , a_c_e , _bcd_ , a___e , true },
32+ { " difference" , a_c_e , _bcd_ , a___e , false },
33+ { " equals" , abcde , abcde , true , },
34+ { " equals" , abcde , abcd_ , false , },
35+ { " intersection_update" , a_c_e , _bcd_ , __c__ , true },
36+ { " intersection" , a_c_e , _bcd_ , __c__ , false },
37+ { " isdisjoint" , _b_d_ , ___de , false , },
38+ { " isdisjoint" , _b_d_ , a___e , true , },
39+ { " isempty" , _____ , nil , true , },
40+ { " isempty" , abcde , nil , false , },
41+ { " issubset" , abcd_ , abcde , true , },
42+ { " issubset" , abcde , abcd_ , false , },
43+ { " issuperset" , abcd_ , abcde , false , },
44+ { " issuperset" , abcde , abcd_ , true , },
45+ { " len" , _____ , nil , 0 , },
46+ { " len" , a_c__ , nil , 2 , },
47+ { " map" , abc__ , upper , ABC__ , false },
48+ { " pop" , _____ , nil , nil , },
49+ { " remove" , _bcd_ , " c" , _b_d_ , true },
50+ { " symmetric_difference_update" , a_c_e , _bcd_ , ab_de , true },
51+ { " symmetric_difference" , a_c_e , _bcd_ , ab_de , false },
52+ { " union" , abc__ , ___de , abcde , false },
53+ { " update" , abc__ , ___de , abcde , true },
54+ { " values" , _____ , nil , {} , },
5355 }
5456
5557 for i = 1 , # tests do
@@ -61,9 +63,9 @@ describe("mods.Set", function()
6163 assert .are_same (expected , res )
6264
6365 if same_ref then
64- assert .are_equal (set , res , " Expected same set instance" )
66+ assert .are_equal (true , rawequal ( set , res ) , " Expected same set instance" )
6567 else
66- assert .not_equal ( set , res , " Expected different set instances" )
68+ assert .are_equal ( false , rawequal ( set , res ) , " Expected different set instances" )
6769 end
6870 end )
6971 end
@@ -114,6 +116,12 @@ describe("mods.Set", function()
114116 assert .are_same ({ b = true , x = true }, b )
115117 end )
116118
119+ it (" __eq returns set member equality" , function ()
120+ assert .is_true (Set ({ " a" , " b" }) == Set ({ " b" , " a" }))
121+ assert .is_false (Set ({ " a" , " b" }) == Set ({ " a" , " c" }))
122+ assert .is_false (Set ({ " a" , " b" }) == Set ({ " a" , " b" , " c" }))
123+ end )
124+
117125 it (" __le returns subset check" , function ()
118126 local a = Set ({ " a" })
119127 local b = Set ({ " a" , " b" })
0 commit comments