Permalink
Browse files

Added some test cases

  • Loading branch information...
nikhilk committed Aug 26, 2012
1 parent efe7bc7 commit 45f1980d1cb1c8b22d6fe3365a0942f0aa239050
Showing with 36 additions and 0 deletions.
  1. +19 −0 tests/CoreLib/TestOOP.htm
  2. +17 −0 tests/CoreLib/TestOOP.js
View
@@ -21,6 +21,7 @@ <h2 id="qunit-userAgent"></h2>
test('isClass', function() {
QUnit.equal(Type.isClass(Test.Cat), true, 'Expected Cat to be a class');
QUnit.equal(Type.isClass(Test.IPet), false, 'Did not expect IPet to be a class');
+ QUnit.equal(Type.isClass(Test.More.Comic), true, 'Expectd Comic to be a class');
});
test('isAssignableFrom', function() {
@@ -69,5 +70,23 @@ <h2 id="qunit-userAgent"></h2>
var g = new Test.Garfield();
QUnit.equal(g.speak(), 'meow\r\nI am fat, lazy, and cynical, but still, a favorite cat...', 'Garfield meows and says something cute');
});
+
+test('getInstanceType', function() {
+ var g = new Test.Garfield();
+ QUnit.equal(Type.getInstanceType(g), Test.Garfield, "Expected Test.Garfield instance.");
+
+ var c = new Test.More.Comic();
+ QUnit.equal(Type.getInstanceType(c), Test.More.Comic, "Expected Test.More.Comic instance.");
+});
+
+test('typeNames', function() {
+ var g = new Test.Garfield();
+ QUnit.equal(Type.getInstanceType(g).get_name(), 'Garfield', "Expected 'Garfield' for type name.");
+ QUnit.equal(Type.getInstanceType(g).get_fullName(), 'Test.Garfield', "Expected 'Test.Garfield' for type name.");
+
+ var c = new Test.More.Comic();
+ QUnit.equal(Type.getInstanceType(c).get_name(), 'Comic', "Expected 'Comic' for type name.");
+ QUnit.equal(Type.getInstanceType(c).get_fullName(), 'Test.More.Comic', "Expected 'Test.More.Comic' for type name.");
+});
</script>
</html>
View
@@ -1,4 +1,5 @@
Type.registerNamespace('Test');
+Type.registerNamespace('Test.More');
////////////////////////////////////////////////////////////////////////////////
// Test.IMammal
@@ -72,6 +73,22 @@ Test.Garfield.prototype = {
}
+////////////////////////////////////////////////////////////////////////////////
+// Test.More.Comic
+
+Test.More.Comic = function(name) {
+ this._name = name;
+}
+Test.More.Comic.prototype = {
+
+ get_name: function() {
+ return this._name;
+ }
+}
+
+
+
Test.Animal.registerClass('Test.Animal');
Test.Cat.registerClass('Test.Cat', Test.Animal, Test.IMammal);
Test.Garfield.registerClass('Test.Garfield', Test.Cat, Test.IPet);
+Test.More.Comic.registerClass('Test.More.Comic');

0 comments on commit 45f1980

Please sign in to comment.