separate number into float and integer
This commit is contained in:
parent
10f55313b0
commit
daab50d54c
22 changed files with 848 additions and 428 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
|
@ -16,13 +17,13 @@ func GetAllTestCases() map[string]AllTestCase {
|
|||
[]Value{
|
||||
&VariableValue{
|
||||
"a",
|
||||
&NumberValue{1},
|
||||
&IntegerValue{new(big.Int).SetInt64(1)},
|
||||
0,
|
||||
},
|
||||
},
|
||||
},
|
||||
"func": {
|
||||
"func sum(a: number, b: number) number {\n\treturn a + b\n}\n_ = sum(1, 2)",
|
||||
"fn sum(a: int, b: int) -> int {\n\treturn a + b\n}\n_ = sum(1, 2)",
|
||||
[]Value{
|
||||
&VariableValue{
|
||||
"sum",
|
||||
|
|
@ -31,11 +32,11 @@ func GetAllTestCases() map[string]AllTestCase {
|
|||
Params: []FunctionParameter{
|
||||
{
|
||||
"a",
|
||||
&NumberSignature{},
|
||||
&IntegerSignature{},
|
||||
},
|
||||
{
|
||||
"b",
|
||||
&NumberSignature{},
|
||||
&IntegerSignature{},
|
||||
},
|
||||
},
|
||||
Chunk: &Chunk{
|
||||
|
|
@ -43,7 +44,7 @@ func GetAllTestCases() map[string]AllTestCase {
|
|||
InstructionDescend,
|
||||
InstructionGetLocal, 0,
|
||||
InstructionGetLocal, 1,
|
||||
InstructionAdd,
|
||||
InstructionAddInt,
|
||||
InstructionReturn,
|
||||
InstructionAscend,
|
||||
},
|
||||
|
|
@ -55,14 +56,14 @@ func GetAllTestCases() map[string]AllTestCase {
|
|||
},
|
||||
},
|
||||
"list": {
|
||||
"a := [1, 2]",
|
||||
"a := [1.0, 2.0]",
|
||||
[]Value{
|
||||
&VariableValue{
|
||||
"a",
|
||||
&ListValue{
|
||||
[]Value{
|
||||
&NumberValue{1},
|
||||
&NumberValue{2},
|
||||
&FloatValue{1},
|
||||
&FloatValue{2},
|
||||
},
|
||||
},
|
||||
0,
|
||||
|
|
@ -76,9 +77,9 @@ func GetAllTestCases() map[string]AllTestCase {
|
|||
"a",
|
||||
&ListValue{
|
||||
[]Value{
|
||||
&NumberValue{1},
|
||||
&NumberValue{2},
|
||||
&NumberValue{3},
|
||||
&IntegerValue{big.NewInt(1)},
|
||||
&IntegerValue{big.NewInt(2)},
|
||||
&IntegerValue{big.NewInt(3)},
|
||||
},
|
||||
},
|
||||
0,
|
||||
|
|
@ -86,14 +87,14 @@ func GetAllTestCases() map[string]AllTestCase {
|
|||
},
|
||||
},
|
||||
"list_concat": {
|
||||
"a := [1, 2]\nb := a + [3]",
|
||||
"a := [1.0, 2.0]\nb := a + [3.0]",
|
||||
[]Value{
|
||||
&VariableValue{
|
||||
"a",
|
||||
&ListValue{
|
||||
[]Value{
|
||||
&NumberValue{1},
|
||||
&NumberValue{2},
|
||||
&FloatValue{1},
|
||||
&FloatValue{2},
|
||||
},
|
||||
},
|
||||
0,
|
||||
|
|
@ -102,9 +103,9 @@ func GetAllTestCases() map[string]AllTestCase {
|
|||
"b",
|
||||
&ListValue{
|
||||
[]Value{
|
||||
&NumberValue{1},
|
||||
&NumberValue{2},
|
||||
&NumberValue{3},
|
||||
&FloatValue{1},
|
||||
&FloatValue{2},
|
||||
&FloatValue{3},
|
||||
},
|
||||
},
|
||||
0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue