integers are printed as such, without .0 part
This commit is contained in:
parent
2a005112be
commit
76307759a4
3 changed files with 15 additions and 2 deletions
|
@ -7,7 +7,6 @@ To run REPL locally: `ruby -Ilib bin/rpl`
|
|||
To run the test suite: `find ./spec/ -name \*.rb -exec ruby -Ilib {} \;`
|
||||
|
||||
# TODO-list
|
||||
* RplNumeric.to_s isn't perfect
|
||||
* pseudo filesystem: subdir for variables
|
||||
* UI toolkit (based on https://github.com/AndyObtiva/glimmer-dsl-libui ?)
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ module Types
|
|||
'<NaN>'
|
||||
elsif @base != 10
|
||||
@value.to_i.to_s( @base )
|
||||
elsif @value.integer?
|
||||
elsif @value.frac.zero?
|
||||
@value.to_i
|
||||
else
|
||||
@value.to_s( 'F' )
|
||||
|
|
|
@ -152,6 +152,20 @@ class TestTypes < MiniTest::Test
|
|||
assert_equal 16, Types.new_object( RplNumeric, '0xfed' ).base
|
||||
assert_equal 8, Types.new_object( RplNumeric, '0o57' ).base
|
||||
assert_equal 13, Types.new_object( RplNumeric, '13bba7' ).base
|
||||
|
||||
assert_equal '1', Types.new_object( RplNumeric, '1' ).to_s
|
||||
assert_equal '1.1', Types.new_object( RplNumeric, '1.1' ).to_s
|
||||
assert_equal '0.1', Types.new_object( RplNumeric, '.1' ).to_s
|
||||
assert_equal '∞', Types.new_object( RplNumeric, '∞' ).to_s
|
||||
assert_equal '-∞', Types.new_object( RplNumeric, '-∞' ).to_s
|
||||
assert_equal '0', Types.new_object( RplNumeric, '0' ).to_s
|
||||
assert_equal '-3', Types.new_object( RplNumeric, '-3' ).to_s
|
||||
assert_equal '-3.456', Types.new_object( RplNumeric, '-3.456' ).to_s
|
||||
assert_equal '-0.456', Types.new_object( RplNumeric, '-.456' ).to_s
|
||||
assert_equal '0b101', Types.new_object( RplNumeric, '0b101' ).to_s
|
||||
assert_equal '0xfed', Types.new_object( RplNumeric, '0xfed' ).to_s
|
||||
assert_equal '0o57', Types.new_object( RplNumeric, '0o57' ).to_s
|
||||
assert_equal '13bba7', Types.new_object( RplNumeric, '13bba7' ).to_s
|
||||
end
|
||||
|
||||
def test_list
|
||||
|
|
Loading…
Reference in a new issue