[gjs] installed-tests: Add some more cases for interfaces



commit bbccadad0609902bb21de154ac4fc6d41a2a2f2a
Author: Sam Spilsbury <smspillaz gmail com>
Date:   Thu Jul 2 17:43:38 2015 +0800

    installed-tests: Add some more cases for interfaces
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751343

 installed-tests/js/testGObjectInterface.js |    8 ++++++++
 installed-tests/js/testInterface.js        |   22 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/installed-tests/js/testGObjectInterface.js b/installed-tests/js/testGObjectInterface.js
index 4dd07ce..1546198 100644
--- a/installed-tests/js/testGObjectInterface.js
+++ b/installed-tests/js/testGObjectInterface.js
@@ -122,6 +122,14 @@ function testGObjectClassCanImplementInterface() {
     JSUnit.assertTrue(obj.constructor.implements(AnInterface));
 }
 
+function testRaisesWhenInterfaceRequiresGObjectInterfaceButNotGObject() {
+    JSUnit.assertRaises(() => new Lang.Interface({
+        Name: 'GObjectInterfaceNotRequiringGObject',
+        GTypeName: 'GTypeNameNotRequiringGObject',
+        Requires: [ Gio.Initable ]
+    }));
+}
+
 function testGObjectCanImplementInterfacesFromJSAndC() {
     // Test will fail if the constructor throws an exception
     const ObjectImplementingLangInterfaceAndCInterface = new Lang.Class({
diff --git a/installed-tests/js/testInterface.js b/installed-tests/js/testInterface.js
index c8b130f..db370f7 100644
--- a/installed-tests/js/testInterface.js
+++ b/installed-tests/js/testInterface.js
@@ -109,6 +109,15 @@ function testObjectCanImplementInterface() {
     JSUnit.assertTrue(obj.constructor.implements(AnInterface));
 }
 
+function testSuperclassCanImplementInterface() {
+    const ChildWhoseParentImplementsAnInterface = new Lang.Class({
+        Name: "ChildWhoseParentImplementsAnInterface",
+        Extends: ObjectImplementingAnInterface
+    });
+    let obj = new ChildWhoseParentImplementsAnInterface();
+    JSUnit.assertTrue(obj.constructor.implements(AnInterface));
+}
+
 function testObjectImplementingInterfaceHasCorrectConstructor() {
     let obj = new ObjectImplementingAnInterface();
     JSUnit.assertEquals(ObjectImplementingAnInterface, obj.constructor);
@@ -120,6 +129,14 @@ function testObjectCanImplementRequiredFunction() {
     implementer.required();
 }
 
+function testInterfaceMustHaveName() {
+    JSUnit.assertRaises(function () {
+        const AnInterfaceWithoutAName = new Lang.Interface({
+            required: Lang.Interface.UNIMPLEMENTED
+        });
+    });
+}
+
 function testClassMustImplementRequiredFunction() {
     JSUnit.assertRaises(() => new Lang.Class({
         Name: 'MyBadObject',
@@ -300,4 +317,9 @@ function testSubclassCanReimplementTheSameInterfaceAsItsParent() {
     JSUnit.assertTrue(obj.constructor.implements(AnInterface));
 }
 
+function testToString() {
+    JSUnit.assertEquals('[interface Interface for AnInterface]',
+                        AnInterface.toString());
+}
+
 JSUnit.gjstestRun(this, JSUnit.setUp, JSUnit.tearDown);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]