This repository was archived by the owner on Jun 11, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
main/java/com/caseyjbrooks/clog/parseltongue
orchid/resources/changelog
test/java/com/caseyjbrooks/clog Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -129,13 +129,13 @@ Token getAny() {
129129 ch = chars .removeFirst ();
130130 column ++;
131131
132- if (ch == '#' && chars .peekFirst () == '{' ) {
132+ if (ch == '#' && chars .size () > 0 && chars . peekFirst () == '{' ) {
133133 chars .removeFirst ();
134134 column ++;
135135 ungetTokens .push (new Token (Token .Type .CLOG_START ));
136136 return new Token (Token .Type .ANY , s );
137137 }
138- else if (ch == '{' && chars .peekFirst () == '}' ) {
138+ else if (ch == '{' && chars .size () > 0 && chars . peekFirst () == '}' ) {
139139// chars.removeFirst();
140140// column++;
141141 ungetTokens .push (new Token (Token .Type .CLOG_SIMPLE ));
Original file line number Diff line number Diff line change 1+ ---
2+ version : ' 2.0.7'
3+ ---
4+
5+ - Fixes issue of literal ` # ` crashing parser. Closes #1
Original file line number Diff line number Diff line change @@ -482,6 +482,27 @@ public void testIndexers() {
482482 assertEquals (expectedOutput , output );
483483 }
484484
485+ // Test Bugfixes
486+ //----------------------------------------------------------------------------------------------------------------------
487+
488+ @ Test
489+ public void testBugFixes () {
490+ Parseltongue parseltongue = new Parseltongue ();
491+ parseltongue .findSpells (ParseltongueTest .class );
492+
493+ String input , expectedOutput , output ;
494+
495+ input = "#" ;
496+ expectedOutput = "#" ;
497+ output = parseltongue .format (input );
498+ assertEquals (expectedOutput , output );
499+
500+ input = "# and a #{$1} clog and also another # followed by another #{$2} clog" ;
501+ expectedOutput = "# and a 1 clog and also another # followed by another 2 clog" ;
502+ output = parseltongue .format (input , 1 , 2 );
503+ assertEquals (expectedOutput , output );
504+ }
505+
485506//test spells
486507//--------------------------------------------------------------------------------------------------
487508
You can’t perform that action at this time.
0 commit comments