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

     1  package expressions
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/lmorg/murex/lang/expressions/symbols"
     7  )
     8  
     9  func TestParseQuoteSingle(t *testing.T) {
    10  	tests := expTestsT{
    11  		symbol: symbols.QuoteSingle,
    12  		tests: []expTestT{
    13  			{
    14  				input:    `''`,
    15  				expected: ``,
    16  			},
    17  			{
    18  				input: `'foobar`,
    19  				error: true,
    20  			},
    21  			{
    22  				input:    `'foobar'`,
    23  				expected: `foobar`,
    24  			},
    25  			{
    26  				input:    `'foobar'  `,
    27  				expected: `foobar`,
    28  			},
    29  			{
    30  				input:    ` 'foobar'`,
    31  				expected: `foobar`,
    32  				pos:      1,
    33  			},
    34  			{
    35  				input:    `  'foobar'`,
    36  				expected: `foobar`,
    37  				pos:      2,
    38  			},
    39  			{
    40  				input:    `   'foobar'`,
    41  				expected: `foobar`,
    42  				pos:      3,
    43  			},
    44  			{
    45  				input:    "\t'foobar'",
    46  				expected: `foobar`,
    47  				pos:      1,
    48  			},
    49  			{
    50  				input:    "\t 'foobar'",
    51  				expected: `foobar`,
    52  				pos:      2,
    53  			},
    54  			{
    55  				input:    "\t\t  'foobar'",
    56  				expected: `foobar`,
    57  				pos:      4,
    58  			},
    59  			{
    60  				input:    `  'foobar'  `,
    61  				expected: `foobar`,
    62  				pos:      2,
    63  			},
    64  			{
    65  				input:    `'foo bar'`,
    66  				expected: `foo bar`,
    67  			},
    68  			{
    69  				input:    `'foobar"'`,
    70  				expected: `foobar"`,
    71  			},
    72  			{
    73  				input:    `'foobar\'`,
    74  				expected: `foobar\`,
    75  			},
    76  			{
    77  				input: `'foobar\''`,
    78  				error: true,
    79  			},
    80  			{
    81  				input:    `'foo-$bar-bar'`,
    82  				expected: `foo-$bar-bar`,
    83  			},
    84  			{
    85  				input:    `'foo-$(bar)-bar'`,
    86  				expected: `foo-$(bar)-bar`,
    87  			},
    88  			{
    89  				input:    `'foo-@bar-bar'`,
    90  				expected: `foo-@bar-bar`,
    91  			},
    92  			{
    93  				input:    `'\s'`,
    94  				expected: `\s`,
    95  			},
    96  			{
    97  				input:    `'\t'`,
    98  				expected: `\t`,
    99  			},
   100  			{
   101  				input:    `'\r'`,
   102  				expected: `\r`,
   103  			},
   104  			{
   105  				input:    `'\n'`,
   106  				expected: `\n`,
   107  			},
   108  		},
   109  	}
   110  
   111  	testParserSymbol(t, tests)
   112  }