Skip to content

Commit

Permalink
tests [made]: Added Dictionary tests
Browse files Browse the repository at this point in the history
Fixed a couple of minor quirks in various tests and added tests
for dictionary testing

Signed-off-by: Vihan B <contact@vihan.org>
  • Loading branch information
vihanb committed Dec 10, 2016
1 parent c579928 commit 1808332
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions test/cheddar/class.cheddar
Expand Up @@ -9,6 +9,10 @@ class Animal (public string: name, public number: age) {
return "U CANT FUSE ANIMALS TOGETHER SILLY";
}

unary op - (a) {
return "YOU CANT NEGATE ANIMALS SILLY";
}

func getName -> self.name;
func getAge -> self.age
}
Expand All @@ -21,3 +25,4 @@ print "My dog's age is %d" % myDog.getAge();
let myGoat: Animal = Animal { "Downgoat", 5 };

print myDog + myGoat;
print -myDog;
3 changes: 2 additions & 1 deletion test/tests/Class/Class.js
Expand Up @@ -13,6 +13,7 @@ My dog's age is 3
Created an animal named Downgoat
Max
Downgoat
U CANT FUSE ANIMALS TOGETHER SILLY`
U CANT FUSE ANIMALS TOGETHER SILLY
YOU CANT NEGATE ANIMALS SILLY`
))
});
7 changes: 6 additions & 1 deletion test/tests/Expression/Assign.js
Expand Up @@ -33,6 +33,11 @@ describe('Assignment', function() {
`let a := 1; a = 2`,
''
))

it('should work with predefined to nil', TestCheddarFrom.Code(
`let a; print a`,
'nil'
))
})

describe('reassignment', function() {
Expand All @@ -56,4 +61,4 @@ describe('Assignment', function() {
'4'
))
})
});
});
16 changes: 14 additions & 2 deletions test/tests/Primitives/Dictionary.js
Expand Up @@ -14,5 +14,17 @@ describe('Dictionary', function(){
'[ 1+1: 2 ]',
''
))
})
});
});

describe('evaluated accessors', function(){
it('should propertly access', TestCheddarFrom.Code(
`print ['a': 'b']['a']`,
'b'
))

it('should propertly set', TestCheddarFrom.Code(
`let d = ['a': 'b']; d['a'] = 'c'; print d['a']`,
'c'
))
});
});

0 comments on commit 1808332

Please sign in to comment.