#93, #94: new category MODE with its test file 02-mode.txt, removed 02-entry.txt, complete other tests with 02-entry.txt content

This commit is contained in:
Louis Rubet 2017-05-29 13:20:38 +02:00
parent c1d5dbca90
commit 245f0331f2
9 changed files with 157 additions and 159 deletions

View file

@ -21,6 +21,12 @@ program::keyword_t program::s_keywords[] =
{ cmd_keyword, "type", &program::type, "show type of stack first entry" },
{ cmd_keyword, "default", &program::rpn_default, "set float representation and precision to default" },
//MODE
{ cmd_undef, "", NULL, "\nMODE"},
{ cmd_keyword, "std", &program::std, "standard floating numbers representation. ex: [25] std" },
{ cmd_keyword, "fix", &program::fix, "fixed point representation. ex: 6 fix" },
{ cmd_keyword, "sci", &program::sci, "scientific floating point representation. ex: 20 sci" },
//REAL
{ cmd_undef, "", NULL, "\nREAL"},
{ cmd_keyword, "+", &program::plus, "addition" },
@ -39,14 +45,8 @@ program::keyword_t program::s_keywords[] =
{ cmd_keyword, "sqr", &program::square, "" },
{ cmd_keyword, "mod", &program::modulo, "modulo" },
{ cmd_keyword, "abs", &program::rpn_abs, "absolute value" },
//REAL representation
{ cmd_undef, "", NULL, "\nREAL REPRESENTATION"},
{ cmd_keyword, "dec", &program::dec, "decimal representation" },
{ cmd_keyword, "hex", &program::hex, "hexadecimal representation" },
{ cmd_keyword, "std", &program::std, "standard floating numbers representation. ex: [25] std" },
{ cmd_keyword, "fix", &program::fix, "fixed point representation. ex: 6 fix" },
{ cmd_keyword, "sci", &program::sci, "scientific floating point representation. ex: 20 sci" },
{ cmd_keyword, "prec", &program::precision, "get float precision in bits when first stack is not a number\n\t"
"set float precision in bits when first stack entry is a number. ex: 256 prec" },
{ cmd_keyword, "round", &program::round, "set float rounding mode.\n\tex: [\"nearest\", \"toward zero\", \"toward +inf\", \"toward -inf\", \"away from zero\"] round" },

View file

@ -1,4 +1,4 @@
#include test/02-entry.txt
#include test/02-mode.txt
#include test/03-general.txt
#include test/04-branch.txt
#include test/05-stack.txt

View file

@ -1,123 +0,0 @@
## ENTRY TEST
default
erase
# real decimal
1
-> stack size should be 1
-> stack should be 1
drop
# real decimal (2)
2.345
-> stack should be 2.345
erase
# real decimal (3)
1 2.345 3 4.9
-> stack size should be 4
-> stack should be 1, 2.345, 3, 4.9
erase
# real hex
0x1234 0x10.10
-> stack should be 0x1.234p+12, 0x1.01p+4
# real hex (2)
dec swap dec swap
-> stack should be 4660, 16.0625
erase
# real binary
0b11001100
-> stack should be 204
erase
# real binary (2)
0b11001100.1101
-> stack should be 204.8125
erase
# real inf, nan
inf
@inf@
+inf
+@inf@
-inf
-@inf@
nan
@nan@
-> stack should be inf, inf, inf, inf, -inf, -inf, nan, nan
erase
# symbol
'test'
-> stack size should be 1
-> stack should be 'test'
erase
# symbol (2)
'test
-> stack size should be 1
-> stack should be 'test'
erase
# symbol (3)
''
-> stack size should be 1
-> stack should be ''
erase
# symbol (4)
'
-> stack size should be 1
-> stack should be ''
erase
# string
"test string"
-> stack size should be 1
-> stack should be "test string"
erase
# string (2)
"test string
-> stack size should be 1
-> stack should be "test string"
erase
# string (3)
"
-> stack size should be 1
-> stack should be ""
erase
# program
<< 'one' >>
-> stack size should be 1
-> stack should be << 'one' >>
erase
# program (2)
<< 'one' 2
-> stack size should be 1
-> stack should be << 'one' 2 >>
erase
# program (3)
<<
-> stack size should be 1
-> stack should be << >>
erase
# program (4)
<< << << <<
-> stack size should be 1
-> stack should be << << << << >> >> >> >>
erase
# program (5)
<< -> n << n 2 * >> >>
-> stack size should be 1
-> stack should be << -> n << n 2 * >> >>
erase

37
test/02-mode.txt Normal file
View file

@ -0,0 +1,37 @@
## MODE
default
erase
# std (1)
erase
1
10 std
-> stack should be 1
# std (2)
3 /
-> stack should be 0.3333333333
# std (3)
3 std
-> stack should be 0.333
# fix (1)
drop
10 fix
1
-> stack should be 1.0000000000
# fix (2)
4 fix
-> stack should be 1.0000
# sci (1)
12 sci
-> stack should be 1.000000000000e+00
# sci (2)
2 sci
-> stack should be 1.00e+00
drop

View file

@ -1,4 +1,6 @@
## GENERAL
default
erase
# version
version

View file

@ -2,38 +2,53 @@
default erase
# std (1)
erase
# real decimal
1
10 std
-> stack size should be 1
-> stack should be 1
# std (2)
3 /
-> stack should be 0.3333333333
# std (3)
3 std
-> stack should be 0.333
# fix (1)
drop
10 fix
1
-> stack should be 1.0000000000
# fix (2)
4 fix
-> stack should be 1.0000
# real decimal (2)
2.345
-> stack should be 2.345
erase
# sci (1)
12 sci
-> stack should be 1.000000000000e+00
# real decimal (3)
1 2.345 3 4.9
-> stack size should be 4
-> stack should be 1, 2.345, 3, 4.9
erase
# sci (2)
2 sci
-> stack should be 1.00e+00
drop
# real hex
0x1234 0x10.10
-> stack should be 0x1.234p+12, 0x1.01p+4
# real hex (2)
dec swap dec swap
-> stack should be 4660, 16.0625
erase
# real binary
0b11001100
-> stack should be 204
erase
# real binary (2)
0b11001100.1101
-> stack should be 204.8125
erase
# real inf, nan
inf
@inf@
+inf
+@inf@
-inf
-@inf@
nan
@nan@
-> stack should be inf, inf, inf, inf, -inf, -inf, nan, nan
erase
# prec (1)
default

View file

@ -3,6 +3,24 @@
default
erase
# string entry
"test string"
-> stack size should be 1
-> stack should be "test string"
erase
# string entry (2)
"test string
-> stack size should be 1
-> stack should be "test string"
erase
# string entry (3)
"
-> stack size should be 1
-> stack should be ""
erase
# ->str on real (1)
1
->str

View file

@ -1,5 +1,29 @@
## VARS
# symbol entry
'test'
-> stack size should be 1
-> stack should be 'test'
erase
# symbol entry (2)
'test
-> stack size should be 1
-> stack should be 'test'
erase
# symbol entry (3)
''
-> stack size should be 1
-> stack should be ''
erase
# symbol entry (4)
'
-> stack size should be 1
-> stack should be ''
erase
# sto (1)
1 'a' sto
-> stack size should be 0

View file

@ -1,8 +1,33 @@
## PROGRAM
# program entry
<< 1 >> dup eval
-> stack should be << 1 >>, 1
# program
<< 'one' >>
-> stack size should be 1
-> stack should be << 'one' >>
erase
# program (2)
<< 'one' 2
-> stack size should be 1
-> stack should be << 'one' 2 >>
erase
# program (3)
<<
-> stack size should be 1
-> stack should be << >>
erase
# program (4)
<< << << <<
-> stack size should be 1
-> stack should be << << << << >> >> >> >>
erase
# program (5)
<< -> n << n 2 * >> >>
-> stack size should be 1
-> stack should be << -> n << n 2 * >> >>
erase
# program imbrication