github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/lang/expressions/parse_number_test.go (about)

     1  package expressions
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/lmorg/murex/lang/expressions/symbols"
     7  )
     8  
     9  func TestParseNumber(t *testing.T) {
    10  	tests := expTestsT{
    11  		symbol: symbols.Number,
    12  		tests: []expTestT{
    13  			{
    14  				input:    `0`,
    15  				expected: `0`,
    16  			},
    17  			{
    18  				input:    `0  `,
    19  				expected: `0`,
    20  			},
    21  			{
    22  				input:    `12  `,
    23  				expected: `12`,
    24  			},
    25  			{
    26  				input:    ` 0`,
    27  				expected: `0`,
    28  				pos:      1,
    29  			},
    30  			{
    31  				input:    ` 12`,
    32  				expected: `12`,
    33  				pos:      1,
    34  			},
    35  			{
    36  				input:    `  0`,
    37  				expected: `0`,
    38  				pos:      2,
    39  			},
    40  			{
    41  				input:    `   0`,
    42  				expected: `0`,
    43  				pos:      3,
    44  			},
    45  			{
    46  				input:    "\t0",
    47  				expected: `0`,
    48  				pos:      1,
    49  			},
    50  			{
    51  				input:    "\t 0",
    52  				expected: `0`,
    53  				pos:      2,
    54  			},
    55  			{
    56  				input:    "\t\t  0",
    57  				expected: `0`,
    58  				pos:      4,
    59  			},
    60  			{
    61  				input:    `  0  `,
    62  				expected: `0`,
    63  				pos:      2,
    64  			},
    65  			{
    66  				input:    `  123  `,
    67  				expected: `123`,
    68  				pos:      2,
    69  			},
    70  			{
    71  				input:    `0 0`,
    72  				expected: `0`,
    73  			},
    74  			///
    75  			{
    76  				input:    `0.1`,
    77  				expected: `0.1`,
    78  			},
    79  			{
    80  				input:    `012`,
    81  				expected: `012`,
    82  			},
    83  		},
    84  	}
    85  
    86  	testParserSymbol(t, tests)
    87  }