Permalink
Browse files

Returning proper values for default false values (how could that have…

… slipped? :O )
  • Loading branch information...
cpojer committed May 8, 2012
1 parent fac6ebf commit b2bd63242d5af90c2da2b047fd7447bd4b84dd4a
Showing with 21 additions and 1 deletion.
  1. +1 −1 Source/Class.Properties.js
  2. +20 −0 Specs/Class.Properties.js
@@ -27,7 +27,7 @@ var setter = function(name){
var getter = function(name){
return function(){
- return this[name] || null;
+ return this[name] !== undefined ? this[name] : null;
};
};
View
@@ -140,4 +140,24 @@ describe('Class.Properties', function(){
expect(italian.getAge()).toEqual(15);
});
+ it('should return proper false values', function() {
+ var Human = new Class({
+
+ Properties: {
+ name: 'Mario',
+ lastName: '',
+ age: 0,
+ gender: undefined,
+ bool: false
+ }
+
+ });
+
+ var italian = new Human;
+ expect(italian.getLastName()).toEqual('');
+ expect(italian.getAge()).toEqual(0);
+ expect(italian.getGender()).toEqual(null);
+ expect(italian.getBool()).toEqual(false);
+ });
+
});

0 comments on commit b2bd632

Please sign in to comment.