[gjs: 2/3] added various test cases for this enhancement




commit fbd0bb6b8d417520faacb15ee9ffde6f6d176923
Author: Nasah Kuma <nasahnash19 gmail com>
Date:   Tue Mar 22 19:49:07 2022 +0100

    added various test cases for this enhancement

 installed-tests/js/testPrint.js | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
---
diff --git a/installed-tests/js/testPrint.js b/installed-tests/js/testPrint.js
index 50a4ebc2a..f6d274057 100644
--- a/installed-tests/js/testPrint.js
+++ b/installed-tests/js/testPrint.js
@@ -48,12 +48,29 @@ describe('prettyPrint', function () {
         log({greeting: 'hi'});
     });
 
+    it('property value is object reference', function () {
+        GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_MESSAGE,
+            'JS LOG: { a: 5, b: [Circular] }');
+        let obj = {a: 5};
+        obj.b = obj;
+        log(obj);
+    });
+
     it('more than one property', function () {
         GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_MESSAGE,
             'JS LOG: { a: 1, b: 2, c: 3 }');
         log({a: 1, b: 2, c: 3});
     });
 
+    it('add property value after property value object reference', function () {
+        GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_MESSAGE,
+            'JS LOG: { a: 5, b: [Circular], c: 4 }');
+        let obj = {a: 5};
+        obj.b = obj;
+        obj.c = 4;
+        log(obj);
+    });
+
     it('array', function () {
         GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_MESSAGE,
             'JS LOG: [1, 2, 3, 4, 5]');
@@ -66,6 +83,24 @@ describe('prettyPrint', function () {
         log({arr: [1, 2, 3, 4, 5]});
     });
 
+    it('array reference is the only array element', function () {
+        GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_MESSAGE,
+            'JS LOG: [[Circular]]');
+        let arr = [];
+        arr.push(arr);
+        log(arr);
+    });
+
+    it('array reference is one of multiple array elements', function () {
+        GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_MESSAGE,
+            'JS LOG: [4, [Circular], 5]');
+        let arr = [];
+        arr.push(4);
+        arr.push(arr);
+        arr.push(5);
+        log(arr);
+    });
+
     it('nested array', function () {
         GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_MESSAGE,
             'JS LOG: [1, 2, [3, 4], 5]');


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