From 8e9815f30a89c1079d531272a4e51efe38178260 Mon Sep 17 00:00:00 2001 From: s-ol Date: Sat, 13 Nov 2021 18:13:47 +0100 Subject: fix pretty-printing for "false" values --- spec/result/const_spec.moon | 5 +++++ spec/result/evt_spec.moon | 16 ++++++++++++++++ spec/result/sig_spec.moon | 5 +++++ spec/type_spec.moon | 2 ++ 4 files changed, 28 insertions(+) (limited to 'spec') diff --git a/spec/result/const_spec.moon b/spec/result/const_spec.moon index a6ab43e..3f31306 100644 --- a/spec/result/const_spec.moon +++ b/spec/result/const_spec.moon @@ -16,6 +16,11 @@ describe 'Constant', -> assert.has.error -> Constant T.num assert.has.no.error -> Constant T.bool, false + it 'stringifies well', -> + assert.is.equal "", tostring Constant.num 4 + assert.is.equal "", tostring Constant.bool true + assert.is.equal "", tostring Constant.bool false + describe '.wrap', -> it 'wraps numbers', -> got = Constant.wrap 3 diff --git a/spec/result/evt_spec.moon b/spec/result/evt_spec.moon index c9416db..46d4cec 100644 --- a/spec/result/evt_spec.moon +++ b/spec/result/evt_spec.moon @@ -5,6 +5,22 @@ import Op, Builtin from require 'alv.base' setup do_setup describe 'EvtStream', -> + it 'stringifies well', -> + number = EvtStream T.num + assert.is.equal "", tostring number + + number\set 4 + assert.is.equal "", tostring number + + bool = EvtStream T.bool + bool\set true + assert.is.equal "", tostring bool + + COPILOT\next_tick! + + bool\set false + assert.is.equal "", tostring bool + describe ':unwrap', -> it 'returns the set value', -> stream = EvtStream T.num diff --git a/spec/result/sig_spec.moon b/spec/result/sig_spec.moon index 1a92bdc..65363bc 100644 --- a/spec/result/sig_spec.moon +++ b/spec/result/sig_spec.moon @@ -5,6 +5,11 @@ import Op, Builtin from require 'alv.base' setup do_setup describe 'SigStream', -> + it 'stringifies well', -> + assert.is.equal "", tostring SigStream T.num, 4 + assert.is.equal "", tostring SigStream T.bool, true + assert.is.equal "", tostring SigStream T.bool, false + describe ':unwrap', -> it 'returns the raw value!', -> assert.is.equal 3.14, (SigStream T.num, 3.14)\unwrap! diff --git a/spec/type_spec.moon b/spec/type_spec.moon index 0293385..727e90b 100644 --- a/spec/type_spec.moon +++ b/spec/type_spec.moon @@ -29,6 +29,8 @@ describe 'Primitive', -> it ':pp pretty-prints values', -> assert.is.equal 'true', bool\pp true + assert.is.equal 'false', bool\pp false + assert.is.equal 'nil', bool\pp nil assert.is.equal '4.134', num\pp 4.134 assert.is.equal '"hello"', str\pp "hello" -- cgit v1.2.3