Home page Forum Wiki Mail Jabber Devel NIX-FILES

AltLUG Git

Git-repositories of Altai Linux User Group

Allow objects with no prototype to tested against object literals.
[qunit.git] / test / same.js
index fa7e3eb..3783275 100644 (file)
@@ -136,6 +136,17 @@ test("Objects Basics.", function() {
             a: [{ bat: undefined }]
         }
     ), false);
+
+    // Objects with no prototype, created via Object.create(null), are used e.g. as dictionaries.
+    // Being able to test equivalence against object literals is quite useful.
+    if (Object.create) {
+        equals(QUnit.equiv(Object.create(null), {}), true, "empty object with no prototype VS empty object");
+
+        var nonEmptyWithNoProto = Object.create(null);
+        nonEmptyWithNoProto.foo = "bar";
+
+        equals(QUnit.equiv(nonEmptyWithNoProto, { foo: "bar" }), true, "nonempty object with no prototype VS empty object");
+    }
 });
 
 

Hosting is provided AltSPAHow to use Git
Please direct any questions on jabber alex.wolf@jabber.ru

Valid HTML 4.0 Transitional Valid CSS!

Designer Alexander Wolf