mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Tweaked truthiness, fixed int to float coersion
This commit is contained in:
80
tests/integrations/test_truthiness.toy
Normal file
80
tests/integrations/test_truthiness.toy
Normal file
@@ -0,0 +1,80 @@
|
||||
//booleans
|
||||
{
|
||||
var value = true;
|
||||
|
||||
if (value) {
|
||||
print "correct";
|
||||
}
|
||||
else {
|
||||
assert false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var value = false;
|
||||
|
||||
if (value) {
|
||||
assert false;
|
||||
}
|
||||
else {
|
||||
print "correct";
|
||||
}
|
||||
}
|
||||
|
||||
//integers
|
||||
{
|
||||
var value: int = 42;
|
||||
|
||||
if (value) {
|
||||
print "correct";
|
||||
}
|
||||
else {
|
||||
assert false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var value: int = 0;
|
||||
|
||||
if (value) {
|
||||
assert false;
|
||||
}
|
||||
else {
|
||||
print "correct";
|
||||
}
|
||||
}
|
||||
|
||||
//floats
|
||||
{
|
||||
var value: float = 42.8891;
|
||||
|
||||
if (value) {
|
||||
print "correct";
|
||||
}
|
||||
else {
|
||||
assert false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var value: float = 0;
|
||||
|
||||
if (value) {
|
||||
assert false;
|
||||
}
|
||||
else {
|
||||
print "correct";
|
||||
}
|
||||
}
|
||||
|
||||
//everything else
|
||||
{
|
||||
var value: string = "foobar";
|
||||
|
||||
if (value) {
|
||||
print "correct";
|
||||
}
|
||||
else {
|
||||
assert false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user