From 5d5d6638fedc7987123b3f065decc58d9b14f7da Mon Sep 17 00:00:00 2001 From: Adam Grant Date: Thu, 21 Nov 2019 16:38:28 -0800 Subject: [PATCH] Fixing function return bug --- docs.js | 8 +++++++- mozart.js | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs.js b/docs.js index 5f4722b..55fd02b 100644 --- a/docs.js +++ b/docs.js @@ -57,7 +57,13 @@ var assert, body, test; -assert = (message, actual, expected) => [actual == expected, actual, expected, message]; +assert = (message, actual, expected) => { + expected = typeof(expected) == "object" ? JSON.stringify(expected) : expected; + actual = typeof(actual) == "object" ? JSON.stringify(actual) : actual; + + return [actual == expected, actual, expected, message]; +} + test = (term, assertions, sandbox) => { if (sandbox) { document.getElementById("test-sandbox").innerHTML = sandbox; diff --git a/mozart.js b/mozart.js index eb943d8..8cbb2cd 100644 --- a/mozart.js +++ b/mozart.js @@ -38,7 +38,7 @@ class Mozart { acts(obj) { var public_obj = this.parse_object(obj.priv, (obj, args, key) => { var _$ = this.scoped_selector(); - obj[key](_$, args); + return obj[key](_$, args); }); this.add_object_method("act", public_obj, true); @@ -46,7 +46,7 @@ class Mozart { var private_obj = this.parse_object(obj, (obj, args, key) => { var _$ = this.scoped_selector(); - obj[key](_$, args); + return obj[key](_$, args); }); this.add_object_method("act", private_obj);