Symbol: test coverage for empty and bool

oh yeah
yet another opportunity for mistakes
This commit is contained in:
Fischlurch 2017-04-07 20:06:19 +02:00
parent 4df59678a3
commit 2204066a94
3 changed files with 17 additions and 4 deletions

View file

@ -123,6 +123,9 @@ namespace lib {
Symbol& operator= (Symbol const&) = default;
Symbol& operator= (Symbol &&) = default;
explicit operator bool() const { return not empty(); }
bool empty() const { return *this == BOTTOM; }
};

View file

@ -540,8 +540,8 @@ END
TEST "Symbol_test" Symbol_test <<END
out: one
out: sizeof. Literal.+ = (4|8)
out-lit: string
out-lit: string
out-lit: onenight
out-lit: minus one
out-lit: one....one
return: 0
END

View file

@ -80,8 +80,10 @@ namespace test{
CHECK (li2 != li3);
CHECK (li3 != li2);
cout << typeStr (li1 + string("ce")) << endl;
cout << typeStr (string("minus " +li1)) << endl;
CHECK ("string" == typeStr (li1 + string{"night"}));
CHECK ("string" == typeStr (string{"minus " +li1}));
cout << li1 + string{"night"} << endl;
cout << string{"minus " +li1} << endl;
cout << li2+string("..") << string("..")+li2 << endl;
CHECK (hash_value(li1) == hash_value(li2));
@ -117,9 +119,17 @@ namespace test{
CHECK (sy1.c() == sy2.c());
Symbol sy3;
CHECK (not sy3);
CHECK (sy3 == "");
CHECK (isnil(sy3));
CHECK (sy1 != sy3);
CHECK (not Symbol{""});
CHECK (sy3 == Symbol{""});
CHECK (sy3.c() == Symbol{""}.c());
CHECK (Symbol{}.c() == Symbol{""}.c());
// re-assignment
sy3 = Symbol{l1};
CHECK (!isnil(sy3));
CHECK (sy1 == sy3);