git.s-ol.nu alive / ec8d462
fix pretty-printing for "false" values s-ol 5 months ago
5 changed file(s) with 29 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2626 -- @treturn Result
2727
2828 __tostring: =>
29 if @value then
29 if @value != nil then
3030 "<#{@type}#{@metatype} #{@type\pp @value}>"
3131 else
3232 "<#{@type}#{@metatype}>"
1414 assert.has.error -> Constant.num!
1515 assert.has.error -> Constant T.num
1616 assert.has.no.error -> Constant T.bool, false
17
18 it 'stringifies well', ->
19 assert.is.equal "<num= 4>", tostring Constant.num 4
20 assert.is.equal "<bool= true>", tostring Constant.bool true
21 assert.is.equal "<bool= false>", tostring Constant.bool false
1722
1823 describe '.wrap', ->
1924 it 'wraps numbers', ->
44 setup do_setup
55
66 describe 'EvtStream', ->
7 it 'stringifies well', ->
8 number = EvtStream T.num
9 assert.is.equal "<num! nil>", tostring number
10
11 number\set 4
12 assert.is.equal "<num! 4>", tostring number
13
14 bool = EvtStream T.bool
15 bool\set true
16 assert.is.equal "<bool! true>", tostring bool
17
18 COPILOT\next_tick!
19
20 bool\set false
21 assert.is.equal "<bool! false>", tostring bool
22
723 describe ':unwrap', ->
824 it 'returns the set value', ->
925 stream = EvtStream T.num
44 setup do_setup
55
66 describe 'SigStream', ->
7 it 'stringifies well', ->
8 assert.is.equal "<num~ 4>", tostring SigStream T.num, 4
9 assert.is.equal "<bool~ true>", tostring SigStream T.bool, true
10 assert.is.equal "<bool~ false>", tostring SigStream T.bool, false
11
712 describe ':unwrap', ->
813 it 'returns the raw value!', ->
914 assert.is.equal 3.14, (SigStream T.num, 3.14)\unwrap!
2828
2929 it ':pp pretty-prints values', ->
3030 assert.is.equal 'true', bool\pp true
31 assert.is.equal 'false', bool\pp false
32 assert.is.equal 'nil', bool\pp nil
3133 assert.is.equal '4.134', num\pp 4.134
3234 assert.is.equal '"hello"', str\pp "hello"
3335