From 0f27618fa691649027cdc4d5bf7e7647dacd56ab Mon Sep 17 00:00:00 2001 From: Joel Thoms Date: Wed, 17 Oct 2018 13:21:43 -0700 Subject: [PATCH] Just().toString() should stringify the value. --- package.json | 2 +- type/Just.js | 2 +- type/__tests__/Just.test.js | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9aa02c0..7693ed7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mojiscript", - "version": "0.5.1", + "version": "0.6.0", "description": "MojiScript is an Async First, opinionated, and functional language designed to have 100% compatibility with JavaScript engines.", "repository": { "type": "git", diff --git a/type/Just.js b/type/Just.js index 7eeeea0..7895961 100644 --- a/type/Just.js +++ b/type/Just.js @@ -1,5 +1,5 @@ function Just(value) { - const toString = () => `Just (${value})` + const toString = () => `Just (${JSON.stringify(value)})` const map = func => Just(func(value)) return Object.freeze({ diff --git a/type/__tests__/Just.test.js b/type/__tests__/Just.test.js index a78fb07..ae0525f 100644 --- a/type/__tests__/Just.test.js +++ b/type/__tests__/Just.test.js @@ -33,13 +33,20 @@ describe('type/Just', () => { expect(actual).toBe(expected) }) - test('toString', () => { + test('Just(888).toString', () => { expect.assertions(1) const expected = 'Just (888)' const actual = Just(888).toString() expect(actual).toBe(expected) }) + test('Just(abc).toString', () => { + expect.assertions(1) + const expected = 'Just ("abc")' + const actual = Just('abc').toString() + expect(actual).toBe(expected) + }) + test('@@type', () => { expect.assertions(1) const expected = Just['@@type']