@@ -13,6 +13,7 @@ import (
1313func TestParser (t * testing.T ) {
1414 xID , _ , _ := newLitToken ([]rune ("x = 1234" ))
1515 s3ID , _ , _ := newLitToken ([]rune ("s3 = 1234" ))
16+ fooSlashes , _ , _ := newLitToken ([]rune ("//foo" ))
1617
1718 regionID , _ , _ := newLitToken ([]rune ("region" ))
1819 regionLit , _ , _ := newLitToken ([]rune (`"us-west-2"` ))
@@ -33,6 +34,8 @@ func TestParser(t *testing.T) {
3334 defaultProfileStmt := newSectionStatement (defaultID )
3435 assumeProfileStmt := newSectionStatement (assumeID )
3536
37+ fooSlashesExpr := newExpression (fooSlashes )
38+
3639 xEQ1234 := newEqualExpr (newExpression (xID ), equalOp )
3740 xEQ1234 .AppendChild (newExpression (numLit ))
3841 xEQColon1234 := newEqualExpr (newExpression (xID ), equalColonOp )
@@ -101,24 +104,32 @@ func TestParser(t *testing.T) {
101104 },
102105 },
103106 {
104- name : "// comment" ,
105- r : bytes .NewBuffer ([]byte (`// foo` )),
107+ name : "// not a comment" ,
108+ r : bytes .NewBuffer ([]byte (`//foo` )),
106109 expectedStack : []AST {
107- newCommentStatement ( newToken ( TokenComment , [] rune ( "// foo" ), NoneType )) ,
110+ fooSlashesExpr ,
108111 },
109112 },
110113 {
111114 name : "multiple comments" ,
112115 r : bytes .NewBuffer ([]byte (`;foo
113- //bar
114116 # baz
115117 ` )),
116118 expectedStack : []AST {
117119 newCommentStatement (newToken (TokenComment , []rune (";foo" ), NoneType )),
118- newCommentStatement (newToken (TokenComment , []rune ("//bar" ), NoneType )),
119120 newCommentStatement (newToken (TokenComment , []rune ("# baz" ), NoneType )),
120121 },
121122 },
123+ {
124+ name : "comment followed by skip state" ,
125+ r : bytes .NewBuffer ([]byte (`;foo
126+ //foo
127+ # baz
128+ ` )),
129+ expectedStack : []AST {
130+ newCommentStatement (newToken (TokenComment , []rune (";foo" ), NoneType )),
131+ },
132+ },
122133 {
123134 name : "assignment" ,
124135 r : bytes .NewBuffer ([]byte (`x = 1234` )),
0 commit comments