@@ -64,7 +64,7 @@ func TestPrototypesAdderBridgeExample(t *testing.T) {
64
64
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
65
65
66
66
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
67
- require .Equal (t , "#line 33 " + quotedSketchLocation + "\n void setup();\n #line 46 " + quotedSketchLocation + "\n void loop();\n #line 62 " + quotedSketchLocation + "\n void process(BridgeClient client);\n #line 82 " + quotedSketchLocation + "\n void digitalCommand(BridgeClient client);\n #line 109 " + quotedSketchLocation + "\n void analogCommand(BridgeClient client);\n #line 149 " + quotedSketchLocation + "\n void modeCommand(BridgeClient client);\n #line 33 " + quotedSketchLocation + "\n " , ctx . PrototypesSection )
67
+ require .Contains (t , ctx . SketchSourceAfterArduinoPreprocessing , "#line 33 " + quotedSketchLocation + "\n void setup();\n #line 46 " + quotedSketchLocation + "\n void loop();\n #line 62 " + quotedSketchLocation + "\n void process(BridgeClient client);\n #line 82 " + quotedSketchLocation + "\n void digitalCommand(BridgeClient client);\n #line 109 " + quotedSketchLocation + "\n void analogCommand(BridgeClient client);\n #line 149 " + quotedSketchLocation + "\n void modeCommand(BridgeClient client);\n #line 33 " + quotedSketchLocation + "\n " )
68
68
}
69
69
70
70
func TestPrototypesAdderSketchWithIfDef (t * testing.T ) {
@@ -352,7 +352,7 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
352
352
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
353
353
354
354
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
355
- require .Equal (t , "#line 13 " + quotedSketchLocation + "\n void setup();\n #line 17 " + quotedSketchLocation + "\n void loop();\n #line 13 " + quotedSketchLocation + "\n " , ctx . PrototypesSection )
355
+ require .Contains (t , ctx . SketchSourceAfterArduinoPreprocessing , "#line 13 " + quotedSketchLocation + "\n void setup();\n #line 17 " + quotedSketchLocation + "\n void loop();\n #line 13 " + quotedSketchLocation + "\n " )
356
356
357
357
preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch_with_config" , "sketch_with_config.preprocessed.txt" ), ctx )
358
358
require .Equal (t , preprocessed , strings .Replace (ctx .SketchSourceAfterArduinoPreprocessing , "\r \n " , "\n " , - 1 ))
@@ -393,7 +393,7 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
393
393
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
394
394
395
395
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
396
- require .Equal (t , "" , ctx .PrototypesSection )
396
+ require .Equal (t , ctx . SketchSourceMerged , ctx .SketchSourceAfterArduinoPreprocessing ) // No prototypes added
397
397
}
398
398
399
399
func TestPrototypesAdderSketchNoFunctions (t * testing.T ) {
@@ -431,7 +431,7 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
431
431
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
432
432
433
433
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
434
- require .Equal (t , "" , ctx .PrototypesSection )
434
+ require .Equal (t , ctx . SketchSourceMerged , ctx .SketchSourceAfterArduinoPreprocessing ) // No prototypes added
435
435
}
436
436
437
437
func TestPrototypesAdderSketchWithDefaultArgs (t * testing.T ) {
@@ -469,7 +469,7 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
469
469
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
470
470
471
471
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
472
- require .Equal (t , "#line 4 " + quotedSketchLocation + "\n void setup();\n #line 7 " + quotedSketchLocation + "\n void loop();\n #line 1 " + quotedSketchLocation + "\n " , ctx . PrototypesSection )
472
+ require .Contains (t , ctx . SketchSourceAfterArduinoPreprocessing , "#line 4 " + quotedSketchLocation + "\n void setup();\n #line 7 " + quotedSketchLocation + "\n void loop();\n #line 1 " + quotedSketchLocation + "\n " )
473
473
}
474
474
475
475
func TestPrototypesAdderSketchWithInlineFunction (t * testing.T ) {
@@ -509,7 +509,7 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
509
509
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
510
510
511
511
expected := "#line 1 " + quotedSketchLocation + "\n void setup();\n #line 2 " + quotedSketchLocation + "\n void loop();\n #line 4 " + quotedSketchLocation + "\n short unsigned int testInt();\n #line 8 " + quotedSketchLocation + "\n static int8_t testInline();\n #line 12 " + quotedSketchLocation + "\n __attribute__((always_inline)) uint8_t testAttribute();\n #line 1 " + quotedSketchLocation + "\n "
512
- obtained := ctx .PrototypesSection
512
+ obtained := ctx .SketchSourceAfterArduinoPreprocessing
513
513
// ctags based preprocessing removes "inline" but this is still OK
514
514
// TODO: remove this exception when moving to a more powerful parser
515
515
expected = strings .Replace (expected , "static inline int8_t testInline();" , "static int8_t testInline();" , - 1 )
@@ -518,7 +518,7 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
518
518
// TODO: remove this exception when moving to a more powerful parser
519
519
expected = strings .Replace (expected , "__attribute__((always_inline)) uint8_t testAttribute();" , "uint8_t testAttribute();" , - 1 )
520
520
obtained = strings .Replace (obtained , "__attribute__((always_inline)) uint8_t testAttribute();" , "uint8_t testAttribute();" , - 1 )
521
- require .Equal (t , expected , obtained )
521
+ require .Contains (t , obtained , expected )
522
522
}
523
523
524
524
func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF (t * testing.T ) {
@@ -556,7 +556,7 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
556
556
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
557
557
558
558
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
559
- require .Equal (t , "#line 1 " + quotedSketchLocation + "\n void setup();\n #line 3 " + quotedSketchLocation + "\n void loop();\n #line 15 " + quotedSketchLocation + "\n int8_t adalight();\n #line 1 " + quotedSketchLocation + "\n " , ctx . PrototypesSection )
559
+ require .Contains (t , ctx . SketchSourceAfterArduinoPreprocessing , "#line 1 " + quotedSketchLocation + "\n void setup();\n #line 3 " + quotedSketchLocation + "\n void loop();\n #line 15 " + quotedSketchLocation + "\n int8_t adalight();\n #line 1 " + quotedSketchLocation + "\n " )
560
560
}
561
561
562
562
func TestPrototypesAdderSketchWithUSBCON (t * testing.T ) {
@@ -594,7 +594,7 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
594
594
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
595
595
596
596
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
597
- require .Equal (t , "#line 5 " + quotedSketchLocation + "\n void ciao();\n #line 10 " + quotedSketchLocation + "\n void setup();\n #line 15 " + quotedSketchLocation + "\n void loop();\n #line 5 " + quotedSketchLocation + "\n " , ctx . PrototypesSection )
597
+ require .Contains (t , ctx . SketchSourceAfterArduinoPreprocessing , "#line 5 " + quotedSketchLocation + "\n void ciao();\n #line 10 " + quotedSketchLocation + "\n void setup();\n #line 15 " + quotedSketchLocation + "\n void loop();\n #line 5 " + quotedSketchLocation + "\n " )
598
598
}
599
599
600
600
func TestPrototypesAdderSketchWithTypename (t * testing.T ) {
@@ -632,12 +632,12 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
632
632
633
633
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
634
634
expected := "#line 6 " + quotedSketchLocation + "\n void setup();\n #line 10 " + quotedSketchLocation + "\n void loop();\n #line 12 " + quotedSketchLocation + "\n typename Foo<char>::Bar func();\n #line 6 " + quotedSketchLocation + "\n "
635
- obtained := ctx .PrototypesSection
635
+ obtained := ctx .SketchSourceAfterArduinoPreprocessing
636
636
// ctags based preprocessing ignores line with typename
637
637
// TODO: remove this exception when moving to a more powerful parser
638
638
expected = strings .Replace (expected , "#line 12 " + quotedSketchLocation + "\n typename Foo<char>::Bar func();\n " , "" , - 1 )
639
639
obtained = strings .Replace (obtained , "#line 12 " + quotedSketchLocation + "\n typename Foo<char>::Bar func();\n " , "" , - 1 )
640
- require .Equal (t , expected , obtained )
640
+ require .Contains (t , obtained , expected )
641
641
}
642
642
643
643
func TestPrototypesAdderSketchWithIfDef2 (t * testing.T ) {
@@ -675,7 +675,7 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
675
675
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
676
676
677
677
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
678
- require .Equal (t , "#line 5 " + quotedSketchLocation + "\n void elseBranch();\n #line 9 " + quotedSketchLocation + "\n void f1();\n #line 10 " + quotedSketchLocation + "\n void f2();\n #line 12 " + quotedSketchLocation + "\n void setup();\n #line 14 " + quotedSketchLocation + "\n void loop();\n #line 5 " + quotedSketchLocation + "\n " , ctx . PrototypesSection )
678
+ require .Contains (t , ctx . SketchSourceAfterArduinoPreprocessing , "#line 5 " + quotedSketchLocation + "\n void elseBranch();\n #line 9 " + quotedSketchLocation + "\n void f1();\n #line 10 " + quotedSketchLocation + "\n void f2();\n #line 12 " + quotedSketchLocation + "\n void setup();\n #line 14 " + quotedSketchLocation + "\n void loop();\n #line 5 " + quotedSketchLocation + "\n " )
679
679
680
680
expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.txt" ), ctx )
681
681
require .Equal (t , expectedSource , strings .Replace (ctx .SketchSourceAfterArduinoPreprocessing , "\r \n " , "\n " , - 1 ))
@@ -716,7 +716,7 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
716
716
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
717
717
718
718
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
719
- require .Equal (t , "#line 2 " + quotedSketchLocation + "\n void ifBranch();\n #line 9 " + quotedSketchLocation + "\n void f1();\n #line 10 " + quotedSketchLocation + "\n void f2();\n #line 12 " + quotedSketchLocation + "\n void setup();\n #line 14 " + quotedSketchLocation + "\n void loop();\n #line 2 " + quotedSketchLocation + "\n " , ctx . PrototypesSection )
719
+ require .Contains (t , ctx . SketchSourceAfterArduinoPreprocessing , "#line 2 " + quotedSketchLocation + "\n void ifBranch();\n #line 9 " + quotedSketchLocation + "\n void f1();\n #line 10 " + quotedSketchLocation + "\n void f2();\n #line 12 " + quotedSketchLocation + "\n void setup();\n #line 14 " + quotedSketchLocation + "\n void loop();\n #line 2 " + quotedSketchLocation + "\n " )
720
720
721
721
expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.SAM.txt" ), ctx )
722
722
require .Equal (t , expectedSource , strings .Replace (ctx .SketchSourceAfterArduinoPreprocessing , "\r \n " , "\n " , - 1 ))
@@ -757,7 +757,7 @@ func TestPrototypesAdderSketchWithConst(t *testing.T) {
757
757
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
758
758
759
759
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
760
- require .Equal (t , "#line 1 " + quotedSketchLocation + "\n void setup();\n #line 2 " + quotedSketchLocation + "\n void loop();\n #line 4 " + quotedSketchLocation + "\n const __FlashStringHelper* test();\n #line 6 " + quotedSketchLocation + "\n const int test3();\n #line 8 " + quotedSketchLocation + "\n volatile __FlashStringHelper* test2();\n #line 10 " + quotedSketchLocation + "\n volatile int test4();\n #line 1 " + quotedSketchLocation + "\n " , ctx . PrototypesSection )
760
+ require .Contains (t , ctx . SketchSourceAfterArduinoPreprocessing , "#line 1 " + quotedSketchLocation + "\n void setup();\n #line 2 " + quotedSketchLocation + "\n void loop();\n #line 4 " + quotedSketchLocation + "\n const __FlashStringHelper* test();\n #line 6 " + quotedSketchLocation + "\n const int test3();\n #line 8 " + quotedSketchLocation + "\n volatile __FlashStringHelper* test2();\n #line 10 " + quotedSketchLocation + "\n volatile int test4();\n #line 1 " + quotedSketchLocation + "\n " )
761
761
}
762
762
763
763
func TestPrototypesAdderSketchWithDosEol (t * testing.T ) {
0 commit comments