Skip to content

Commit 027014b

Browse files
committed
fix: update test cases in stage 12 to include additional operators and correct string formatting
1 parent 61c14fd commit 027014b

File tree

2 files changed

+77
-76
lines changed

2 files changed

+77
-76
lines changed

internal/stage12.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func testStrings(stageHarness *test_case_harness.TestCaseHarness) error {
1515

1616
logger := stageHarness.Logger
1717

18-
string1 := random.RandomElementFromArray(QUOTED_STRINGS) + " " + "\"unterminated"
18+
string1 := random.RandomElementFromArray(QUOTED_STRINGS) + " " + random.RandomElementFromArray(SINGLE_CHAR_OPERATORS) + " " + "\"unterminated"
1919
string2 := `"foo bar 123 // hello world!"`
2020
shuffledString2 := "(" + strings.Join(random.RandomElementsFromArray(QUOTED_STRINGS, 2), "+") + `) != "other_string"`
2121

internal/test_helpers/fixtures/pass_scanning

Lines changed: 76 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,14 @@ Debug = true
286286
[stage-12] [test-1] ✓ Received exit code 0.
287287
[stage-12] [test-2] Running test case: 2
288288
[stage-12] [test-2] Writing contents to ./test.lox:
289-
[stage-12] [test-2.lox] "bar" "unterminated
289+
[stage-12] [test-2.lox] "bar" ; "unterminated
290290
[stage-12] [test-2] $ ./your_program.sh tokenize test.lox
291291
[your_program] [line 1] Error: Unterminated string.
292292
[your_program] STRING "bar" bar
293+
[your_program] SEMICOLON ; null
293294
[your_program] EOF null
294295
[stage-12] [test-2] ✓ 1 line(s) match on stderr
295-
[stage-12] [test-2] ✓ 2 line(s) match on stdout
296+
[stage-12] [test-2] ✓ 3 line(s) match on stdout
296297
[stage-12] [test-2] ✓ Received exit code 65.
297298
[stage-12] [test-3] Running test case: 3
298299
[stage-12] [test-3] Writing contents to ./test.lox:
@@ -304,12 +305,12 @@ Debug = true
304305
[stage-12] [test-3] ✓ Received exit code 0.
305306
[stage-12] [test-4] Running test case: 4
306307
[stage-12] [test-4] Writing contents to ./test.lox:
307-
[stage-12] [test-4.lox] ("hello"+"bar") != "other_string"
308+
[stage-12] [test-4.lox] ("hello"+"foo") != "other_string"
308309
[stage-12] [test-4] $ ./your_program.sh tokenize test.lox
309310
[your_program] LEFT_PAREN ( null
310311
[your_program] STRING "hello" hello
311312
[your_program] PLUS + null
312-
[your_program] STRING "bar" bar
313+
[your_program] STRING "foo" foo
313314
[your_program] RIGHT_PAREN ) null
314315
[your_program] BANG_EQUAL != null
315316
[your_program] STRING "other_string" other_string
@@ -333,12 +334,14 @@ Debug = true
333334
[stage-11] [test-1] ✓ Received exit code 65.
334335
[stage-11] [test-2] Running test case: 2
335336
[stage-11] [test-2] Writing contents to ./test.lox:
336-
[stage-11] [test-2.lox] 
337-
[stage-11] [test-2.lox] <|TAB|> @
337+
[stage-11] [test-2.lox] @
338+
[stage-11] [test-2.lox] %#
338339
[stage-11] [test-2] $ ./your_program.sh tokenize test.lox
339-
[your_program] [line 2] Error: Unexpected character: @
340+
[your_program] [line 1] Error: Unexpected character: @
341+
[your_program] [line 2] Error: Unexpected character: %
342+
[your_program] [line 2] Error: Unexpected character: #
340343
[your_program] EOF null
341-
[stage-11] [test-2] ✓ 1 line(s) match on stderr
344+
[stage-11] [test-2] ✓ 3 line(s) match on stderr
342345
[stage-11] [test-2] ✓ 1 line(s) match on stdout
343346
[stage-11] [test-2] ✓ Received exit code 65.
344347
[stage-11] [test-3] Running test case: 3
@@ -371,12 +374,12 @@ Debug = true
371374
[stage-11] [test-3] ✓ Received exit code 65.
372375
[stage-11] [test-4] Running test case: 4
373376
[stage-11] [test-4] Writing contents to ./test.lox:
374-
[stage-11] [test-4.lox] ({; $})
377+
[stage-11] [test-4.lox] ({+ #})
375378
[stage-11] [test-4] $ ./your_program.sh tokenize test.lox
376-
[your_program] [line 1] Error: Unexpected character: $
379+
[your_program] [line 1] Error: Unexpected character: #
377380
[your_program] LEFT_PAREN ( null
378381
[your_program] LEFT_BRACE { null
379-
[your_program] SEMICOLON ; null
382+
[your_program] PLUS + null
380383
[your_program] RIGHT_BRACE } null
381384
[your_program] RIGHT_PAREN ) null
382385
[your_program] EOF null
@@ -403,43 +406,41 @@ Debug = true
403406
[stage-10] [test-2] ✓ Received exit code 0.
404407
[stage-10] [test-3] Running test case: 3
405408
[stage-10] [test-3] Writing contents to ./test.lox:
406-
[stage-10] [test-3.lox] {<|TAB|>
409+
[stage-10] [test-3.lox] {<|SPACE|>
407410
[stage-10] [test-3.lox] }
408-
[stage-10] [test-3.lox] ((
409-
[stage-10] [test-3.lox] ;*.+))
411+
[stage-10] [test-3.lox] ((*
412+
[stage-10] [test-3.lox] <|SPACE|>-<|TAB|>))
410413
[stage-10] [test-3] $ ./your_program.sh tokenize test.lox
411414
[your_program] LEFT_BRACE { null
412415
[your_program] RIGHT_BRACE } null
413416
[your_program] LEFT_PAREN ( null
414417
[your_program] LEFT_PAREN ( null
415-
[your_program] SEMICOLON ; null
416418
[your_program] STAR * null
417-
[your_program] DOT . null
418-
[your_program] PLUS + null
419+
[your_program] MINUS - null
419420
[your_program] RIGHT_PAREN ) null
420421
[your_program] RIGHT_PAREN ) null
421422
[your_program] EOF null
422-
[stage-10] [test-3] ✓ 11 line(s) match on stdout
423+
[stage-10] [test-3] ✓ 9 line(s) match on stdout
423424
[stage-10] [test-3] ✓ Received exit code 0.
424425
[stage-10] [test-4] Running test case: 4
425426
[stage-10] [test-4] Writing contents to ./test.lox:
426-
[stage-10] [test-4.lox] {<|TAB|>
427-
[stage-10] [test-4.lox] <|SPACE|><|SPACE|><|TAB|>}
428-
[stage-10] [test-4.lox] ((
429-
[stage-10] [test-4.lox] <=<>-))
427+
[stage-10] [test-4.lox] {<|SPACE|>
428+
[stage-10] [test-4.lox] 
429+
[stage-10] [test-4.lox] <|TAB|><|TAB|>}
430+
[stage-10] [test-4.lox] ((<|SPACE|>,-<=
431+
[stage-10] [test-4.lox] ))
430432
[stage-10] [test-4] $ ./your_program.sh tokenize test.lox
431433
[your_program] LEFT_BRACE { null
432434
[your_program] RIGHT_BRACE } null
433435
[your_program] LEFT_PAREN ( null
434436
[your_program] LEFT_PAREN ( null
435-
[your_program] LESS_EQUAL <= null
436-
[your_program] LESS < null
437-
[your_program] GREATER > null
437+
[your_program] COMMA , null
438438
[your_program] MINUS - null
439+
[your_program] LESS_EQUAL <= null
439440
[your_program] RIGHT_PAREN ) null
440441
[your_program] RIGHT_PAREN ) null
441442
[your_program] EOF null
442-
[stage-10] [test-4] ✓ 11 line(s) match on stdout
443+
[stage-10] [test-4] ✓ 10 line(s) match on stdout
443444
[stage-10] [test-4] ✓ Received exit code 0.
444445
[stage-10] Test passed.
445446

@@ -469,14 +470,14 @@ Debug = true
469470
[stage-9] [test-3] ✓ Received exit code 0.
470471
[stage-9] [test-4] Running test case: 4
471472
[stage-9] [test-4] Writing contents to ./test.lox:
472-
[stage-9] [test-4.lox] ({(!+<)})//Comment
473+
[stage-9] [test-4.lox] ({(<=;.)})//Comment
473474
[stage-9] [test-4] $ ./your_program.sh tokenize test.lox
474475
[your_program] LEFT_PAREN ( null
475476
[your_program] LEFT_BRACE { null
476477
[your_program] LEFT_PAREN ( null
477-
[your_program] BANG ! null
478-
[your_program] PLUS + null
479-
[your_program] LESS < null
478+
[your_program] LESS_EQUAL <= null
479+
[your_program] SEMICOLON ; null
480+
[your_program] DOT . null
480481
[your_program] RIGHT_PAREN ) null
481482
[your_program] RIGHT_BRACE } null
482483
[your_program] RIGHT_PAREN ) null
@@ -509,26 +510,26 @@ Debug = true
509510
[stage-8] [test-2] ✓ Received exit code 0.
510511
[stage-8] [test-3] Running test case: 3
511512
[stage-8] [test-3] Writing contents to ./test.lox:
512-
[stage-8] [test-3.lox] >=<<=<<=
513+
[stage-8] [test-3.lox] >=><<=<
513514
[stage-8] [test-3] $ ./your_program.sh tokenize test.lox
514515
[your_program] GREATER_EQUAL >= null
516+
[your_program] GREATER > null
515517
[your_program] LESS < null
516518
[your_program] LESS_EQUAL <= null
517519
[your_program] LESS < null
518-
[your_program] LESS_EQUAL <= null
519520
[your_program] EOF null
520521
[stage-8] [test-3] ✓ 6 line(s) match on stdout
521522
[stage-8] [test-3] ✓ Received exit code 0.
522523
[stage-8] [test-4] Running test case: 4
523524
[stage-8] [test-4] Writing contents to ./test.lox:
524-
[stage-8] [test-4.lox] (){==>!}
525+
[stage-8] [test-4.lox] (){>====}
525526
[stage-8] [test-4] $ ./your_program.sh tokenize test.lox
526527
[your_program] LEFT_PAREN ( null
527528
[your_program] RIGHT_PAREN ) null
528529
[your_program] LEFT_BRACE { null
530+
[your_program] GREATER_EQUAL >= null
529531
[your_program] EQUAL_EQUAL == null
530-
[your_program] GREATER > null
531-
[your_program] BANG ! null
532+
[your_program] EQUAL = null
532533
[your_program] RIGHT_BRACE } null
533534
[your_program] EOF null
534535
[stage-8] [test-4] ✓ 8 line(s) match on stdout
@@ -572,15 +573,15 @@ Debug = true
572573
[stage-7] [test-3] ✓ Received exit code 0.
573574
[stage-7] [test-4] Running test case: 4
574575
[stage-7] [test-4] Writing contents to ./test.lox:
575-
[stage-7] [test-4.lox] {(==#!$!=)}
576+
[stage-7] [test-4.lox] {(==!=$!%)}
576577
[stage-7] [test-4] $ ./your_program.sh tokenize test.lox
577-
[your_program] [line 1] Error: Unexpected character: #
578578
[your_program] [line 1] Error: Unexpected character: $
579+
[your_program] [line 1] Error: Unexpected character: %
579580
[your_program] LEFT_BRACE { null
580581
[your_program] LEFT_PAREN ( null
581582
[your_program] EQUAL_EQUAL == null
582-
[your_program] BANG ! null
583583
[your_program] BANG_EQUAL != null
584+
[your_program] BANG ! null
584585
[your_program] RIGHT_PAREN ) null
585586
[your_program] RIGHT_BRACE } null
586587
[your_program] EOF null
@@ -623,20 +624,20 @@ Debug = true
623624
[stage-6] [test-3] ✓ Received exit code 0.
624625
[stage-6] [test-4] Running test case: 4
625626
[stage-6] [test-4] Writing contents to ./test.lox:
626-
[stage-6] [test-4.lox] ((%$@=#))
627+
[stage-6] [test-4.lox] ((#===$%))
627628
[stage-6] [test-4] $ ./your_program.sh tokenize test.lox
628-
[your_program] [line 1] Error: Unexpected character: %
629-
[your_program] [line 1] Error: Unexpected character: $
630-
[your_program] [line 1] Error: Unexpected character: @
631629
[your_program] [line 1] Error: Unexpected character: #
630+
[your_program] [line 1] Error: Unexpected character: $
631+
[your_program] [line 1] Error: Unexpected character: %
632632
[your_program] LEFT_PAREN ( null
633633
[your_program] LEFT_PAREN ( null
634+
[your_program] EQUAL_EQUAL == null
634635
[your_program] EQUAL = null
635636
[your_program] RIGHT_PAREN ) null
636637
[your_program] RIGHT_PAREN ) null
637638
[your_program] EOF null
638-
[stage-6] [test-4] ✓ 4 line(s) match on stderr
639-
[stage-6] [test-4] ✓ 6 line(s) match on stdout
639+
[stage-6] [test-4] ✓ 3 line(s) match on stderr
640+
[stage-6] [test-4] ✓ 7 line(s) match on stdout
640641
[stage-6] [test-4] ✓ Received exit code 65.
641642
[stage-6] Test passed.
642643

@@ -665,35 +666,35 @@ Debug = true
665666
[stage-5] [test-2] ✓ Received exit code 65.
666667
[stage-5] [test-3] Running test case: 3
667668
[stage-5] [test-3] Writing contents to ./test.lox:
668-
[stage-5] [test-3.lox] #@$$#
669+
[stage-5] [test-3.lox] @#$#@
669670
[stage-5] [test-3] $ ./your_program.sh tokenize test.lox
670-
[your_program] [line 1] Error: Unexpected character: #
671671
[your_program] [line 1] Error: Unexpected character: @
672-
[your_program] [line 1] Error: Unexpected character: $
672+
[your_program] [line 1] Error: Unexpected character: #
673673
[your_program] [line 1] Error: Unexpected character: $
674674
[your_program] [line 1] Error: Unexpected character: #
675+
[your_program] [line 1] Error: Unexpected character: @
675676
[your_program] EOF null
676677
[stage-5] [test-3] ✓ 5 line(s) match on stderr
677678
[stage-5] [test-3] ✓ 1 line(s) match on stdout
678679
[stage-5] [test-3] ✓ Received exit code 65.
679680
[stage-5] [test-4] Running test case: 4
680681
[stage-5] [test-4] Writing contents to ./test.lox:
681-
[stage-5] [test-4.lox] {(+*-,#;.)}
682+
[stage-5] [test-4.lox] {(+$#.,-@)}
682683
[stage-5] [test-4] $ ./your_program.sh tokenize test.lox
684+
[your_program] [line 1] Error: Unexpected character: $
683685
[your_program] [line 1] Error: Unexpected character: #
686+
[your_program] [line 1] Error: Unexpected character: @
684687
[your_program] LEFT_BRACE { null
685688
[your_program] LEFT_PAREN ( null
686689
[your_program] PLUS + null
687-
[your_program] STAR * null
688-
[your_program] MINUS - null
689-
[your_program] COMMA , null
690-
[your_program] SEMICOLON ; null
691690
[your_program] DOT . null
691+
[your_program] COMMA , null
692+
[your_program] MINUS - null
692693
[your_program] RIGHT_PAREN ) null
693694
[your_program] RIGHT_BRACE } null
694695
[your_program] EOF null
695-
[stage-5] [test-4] ✓ 1 line(s) match on stderr
696-
[stage-5] [test-4] ✓ 11 line(s) match on stdout
696+
[stage-5] [test-4] ✓ 3 line(s) match on stderr
697+
[stage-5] [test-4] ✓ 9 line(s) match on stdout
697698
[stage-5] [test-4] ✓ Received exit code 65.
698699
[stage-5] Test passed.
699700

@@ -728,29 +729,29 @@ Debug = true
728729
[stage-4] [test-2] ✓ Received exit code 0.
729730
[stage-4] [test-3] Running test case: 3
730731
[stage-4] [test-3] Writing contents to ./test.lox:
731-
[stage-4] [test-3.lox] *..,*-+
732+
[stage-4] [test-3.lox] -;+*+;.
732733
[stage-4] [test-3] $ ./your_program.sh tokenize test.lox
733-
[your_program] STAR * null
734-
[your_program] DOT . null
735-
[your_program] DOT . null
736-
[your_program] COMMA , null
737-
[your_program] STAR * null
738734
[your_program] MINUS - null
735+
[your_program] SEMICOLON ; null
736+
[your_program] PLUS + null
737+
[your_program] STAR * null
739738
[your_program] PLUS + null
739+
[your_program] SEMICOLON ; null
740+
[your_program] DOT . null
740741
[your_program] EOF null
741742
[stage-4] [test-3] ✓ 8 line(s) match on stdout
742743
[stage-4] [test-3] ✓ Received exit code 0.
743744
[stage-4] [test-4] Running test case: 4
744745
[stage-4] [test-4] Writing contents to ./test.lox:
745-
[stage-4] [test-4.lox] ({*;+-,})
746+
[stage-4] [test-4.lox] ({,*+.;})
746747
[stage-4] [test-4] $ ./your_program.sh tokenize test.lox
747748
[your_program] LEFT_PAREN ( null
748749
[your_program] LEFT_BRACE { null
750+
[your_program] COMMA , null
749751
[your_program] STAR * null
750-
[your_program] SEMICOLON ; null
751752
[your_program] PLUS + null
752-
[your_program] MINUS - null
753-
[your_program] COMMA , null
753+
[your_program] DOT . null
754+
[your_program] SEMICOLON ; null
754755
[your_program] RIGHT_BRACE } null
755756
[your_program] RIGHT_PAREN ) null
756757
[your_program] EOF null
@@ -780,27 +781,27 @@ Debug = true
780781
[stage-3] [test-2] ✓ Received exit code 0.
781782
[stage-3] [test-3] Running test case: 3
782783
[stage-3] [test-3] Writing contents to ./test.lox:
783-
[stage-3] [test-3.lox] {{{}}
784+
[stage-3] [test-3.lox] {}{}{
784785
[stage-3] [test-3] $ ./your_program.sh tokenize test.lox
785786
[your_program] LEFT_BRACE { null
786-
[your_program] LEFT_BRACE { null
787-
[your_program] LEFT_BRACE { null
788787
[your_program] RIGHT_BRACE } null
788+
[your_program] LEFT_BRACE { null
789789
[your_program] RIGHT_BRACE } null
790+
[your_program] LEFT_BRACE { null
790791
[your_program] EOF null
791792
[stage-3] [test-3] ✓ 6 line(s) match on stdout
792793
[stage-3] [test-3] ✓ Received exit code 0.
793794
[stage-3] [test-4] Running test case: 4
794795
[stage-3] [test-4] Writing contents to ./test.lox:
795-
[stage-3] [test-4.lox] (}{)(})
796+
[stage-3] [test-4.lox] (()})}{
796797
[stage-3] [test-4] $ ./your_program.sh tokenize test.lox
797798
[your_program] LEFT_PAREN ( null
798-
[your_program] RIGHT_BRACE } null
799-
[your_program] LEFT_BRACE { null
800-
[your_program] RIGHT_PAREN ) null
801799
[your_program] LEFT_PAREN ( null
800+
[your_program] RIGHT_PAREN ) null
802801
[your_program] RIGHT_BRACE } null
803802
[your_program] RIGHT_PAREN ) null
803+
[your_program] RIGHT_BRACE } null
804+
[your_program] LEFT_BRACE { null
804805
[your_program] EOF null
805806
[stage-3] [test-4] ✓ 8 line(s) match on stdout
806807
[stage-3] [test-4] ✓ Received exit code 0.
@@ -826,27 +827,27 @@ Debug = true
826827
[stage-2] [test-2] ✓ Received exit code 0.
827828
[stage-2] [test-3] Running test case: 3
828829
[stage-2] [test-3] Writing contents to ./test.lox:
829-
[stage-2] [test-3.lox] ()(()
830+
[stage-2] [test-3.lox] )(()(
830831
[stage-2] [test-3] $ ./your_program.sh tokenize test.lox
831-
[your_program] LEFT_PAREN ( null
832832
[your_program] RIGHT_PAREN ) null
833833
[your_program] LEFT_PAREN ( null
834834
[your_program] LEFT_PAREN ( null
835835
[your_program] RIGHT_PAREN ) null
836+
[your_program] LEFT_PAREN ( null
836837
[your_program] EOF null
837838
[stage-2] [test-3] ✓ 6 line(s) match on stdout
838839
[stage-2] [test-3] ✓ Received exit code 0.
839840
[stage-2] [test-4] Running test case: 4
840841
[stage-2] [test-4] Writing contents to ./test.lox:
841-
[stage-2] [test-4.lox] )())(((
842+
[stage-2] [test-4.lox] ())((()
842843
[stage-2] [test-4] $ ./your_program.sh tokenize test.lox
843-
[your_program] RIGHT_PAREN ) null
844844
[your_program] LEFT_PAREN ( null
845845
[your_program] RIGHT_PAREN ) null
846846
[your_program] RIGHT_PAREN ) null
847847
[your_program] LEFT_PAREN ( null
848848
[your_program] LEFT_PAREN ( null
849849
[your_program] LEFT_PAREN ( null
850+
[your_program] RIGHT_PAREN ) null
850851
[your_program] EOF null
851852
[stage-2] [test-4] ✓ 8 line(s) match on stdout
852853
[stage-2] [test-4] ✓ Received exit code 0.

0 commit comments

Comments
 (0)