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

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