@@ -54,7 +54,7 @@ func TestPrototypesAdderBridgeExample(t *testing.T) {
54
54
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
55
55
56
56
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
57
- 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 )
57
+ 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 " )
58
58
}
59
59
60
60
func TestPrototypesAdderSketchWithIfDef (t * testing.T ) {
@@ -262,7 +262,7 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
262
262
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
263
263
264
264
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
265
- require .Equal (t , "#line 13 " + quotedSketchLocation + "\n void setup();\n #line 17 " + quotedSketchLocation + "\n void loop();\n #line 13 " + quotedSketchLocation + "\n " , ctx . PrototypesSection )
265
+ require .Contains (t , ctx . SketchSourceAfterArduinoPreprocessing , "#line 13 " + quotedSketchLocation + "\n void setup();\n #line 17 " + quotedSketchLocation + "\n void loop();\n #line 13 " + quotedSketchLocation + "\n " )
266
266
267
267
preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch_with_config" , "sketch_with_config.preprocessed.txt" ), ctx )
268
268
require .Equal (t , preprocessed , strings .Replace (ctx .SketchSourceAfterArduinoPreprocessing , "\r \n " , "\n " , - 1 ))
@@ -293,7 +293,7 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
293
293
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
294
294
295
295
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
296
- require .Equal (t , "" , ctx .PrototypesSection )
296
+ require .Equal (t , ctx . SketchSourceMerged , ctx .SketchSourceAfterArduinoPreprocessing ) // No prototypes added
297
297
}
298
298
299
299
func TestPrototypesAdderSketchNoFunctions (t * testing.T ) {
@@ -320,7 +320,7 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
320
320
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
321
321
322
322
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
323
- require .Equal (t , "" , ctx .PrototypesSection )
323
+ require .Equal (t , ctx . SketchSourceMerged , ctx .SketchSourceAfterArduinoPreprocessing ) // No prototypes added
324
324
}
325
325
326
326
func TestPrototypesAdderSketchWithDefaultArgs (t * testing.T ) {
@@ -348,7 +348,7 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
348
348
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
349
349
350
350
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
351
- require .Equal (t , "#line 4 " + quotedSketchLocation + "\n void setup();\n #line 7 " + quotedSketchLocation + "\n void loop();\n #line 1 " + quotedSketchLocation + "\n " , ctx . PrototypesSection )
351
+ require .Contains (t , ctx . SketchSourceAfterArduinoPreprocessing , "#line 4 " + quotedSketchLocation + "\n void setup();\n #line 7 " + quotedSketchLocation + "\n void loop();\n #line 1 " + quotedSketchLocation + "\n " )
352
352
}
353
353
354
354
func TestPrototypesAdderSketchWithInlineFunction (t * testing.T ) {
@@ -378,7 +378,7 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
378
378
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
379
379
380
380
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 "
381
- obtained := ctx .PrototypesSection
381
+ obtained := ctx .SketchSourceAfterArduinoPreprocessing
382
382
// ctags based preprocessing removes "inline" but this is still OK
383
383
// TODO: remove this exception when moving to a more powerful parser
384
384
expected = strings .Replace (expected , "static inline int8_t testInline();" , "static int8_t testInline();" , - 1 )
@@ -387,7 +387,7 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
387
387
// TODO: remove this exception when moving to a more powerful parser
388
388
expected = strings .Replace (expected , "__attribute__((always_inline)) uint8_t testAttribute();" , "uint8_t testAttribute();" , - 1 )
389
389
obtained = strings .Replace (obtained , "__attribute__((always_inline)) uint8_t testAttribute();" , "uint8_t testAttribute();" , - 1 )
390
- require .Equal (t , expected , obtained )
390
+ require .Contains (t , obtained , expected )
391
391
}
392
392
393
393
func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF (t * testing.T ) {
@@ -415,7 +415,7 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
415
415
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
416
416
417
417
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
418
- 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 )
418
+ 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 " )
419
419
}
420
420
421
421
func TestPrototypesAdderSketchWithUSBCON (t * testing.T ) {
@@ -448,7 +448,7 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
448
448
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
449
449
450
450
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
451
- 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 )
451
+ 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 " )
452
452
}
453
453
454
454
func TestPrototypesAdderSketchWithTypename (t * testing.T ) {
@@ -481,12 +481,12 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
481
481
482
482
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
483
483
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 "
484
- obtained := ctx .PrototypesSection
484
+ obtained := ctx .SketchSourceAfterArduinoPreprocessing
485
485
// ctags based preprocessing ignores line with typename
486
486
// TODO: remove this exception when moving to a more powerful parser
487
487
expected = strings .Replace (expected , "#line 12 " + quotedSketchLocation + "\n typename Foo<char>::Bar func();\n " , "" , - 1 )
488
488
obtained = strings .Replace (obtained , "#line 12 " + quotedSketchLocation + "\n typename Foo<char>::Bar func();\n " , "" , - 1 )
489
- require .Equal (t , expected , obtained )
489
+ require .Contains (t , obtained , expected )
490
490
}
491
491
492
492
func TestPrototypesAdderSketchWithIfDef2 (t * testing.T ) {
@@ -514,7 +514,7 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
514
514
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
515
515
516
516
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
517
- 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 )
517
+ 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 " )
518
518
519
519
expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.txt" ), ctx )
520
520
require .Equal (t , expectedSource , strings .Replace (ctx .SketchSourceAfterArduinoPreprocessing , "\r \n " , "\n " , - 1 ))
@@ -545,7 +545,7 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
545
545
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
546
546
547
547
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
548
- 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 )
548
+ 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 " )
549
549
550
550
expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.SAM.txt" ), ctx )
551
551
require .Equal (t , expectedSource , strings .Replace (ctx .SketchSourceAfterArduinoPreprocessing , "\r \n " , "\n " , - 1 ))
@@ -576,7 +576,7 @@ func TestPrototypesAdderSketchWithConst(t *testing.T) {
576
576
NoError (t , builder .PreprocessSketchWithCtags (ctx ))
577
577
578
578
require .Contains (t , ctx .SketchSourceAfterArduinoPreprocessing , "#include <Arduino.h>\n #line 1 " + quotedSketchLocation + "\n " )
579
- 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 )
579
+ 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 " )
580
580
}
581
581
582
582
func TestPrototypesAdderSketchWithDosEol (t * testing.T ) {
0 commit comments