@@ -32,7 +32,6 @@ package test
3232
3333import (
3434 "arduino.cc/builder"
35- "arduino.cc/builder/constants"
3635 "arduino.cc/builder/types"
3736 "github.com/stretchr/testify/require"
3837 "os"
@@ -83,7 +82,7 @@ func TestPrototypesAdderBridgeExample(t *testing.T) {
8382 NoError (t , err )
8483 }
8584
86- require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , context [ constants . CTX_INCLUDE_SECTION ].( string ) )
85+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx . IncludeSection )
8786 require .Equal (t , "#line 33 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 46 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 62 \" " + absoluteSketchLocation + "\" \n void process(BridgeClient client);\n #line 82 \" " + absoluteSketchLocation + "\" \n void digitalCommand(BridgeClient client);\n #line 109 \" " + absoluteSketchLocation + "\" \n void analogCommand(BridgeClient client);\n #line 149 \" " + absoluteSketchLocation + "\" \n void modeCommand(BridgeClient client);\n #line 33 \" " + absoluteSketchLocation + "\" \n " , ctx .PrototypesSection )
8887}
8988
@@ -419,7 +418,7 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
419418 NoError (t , err )
420419 }
421420
422- require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , context [ constants . CTX_INCLUDE_SECTION ].( string ) )
421+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx . IncludeSection )
423422 require .Equal (t , "#line 13 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 17 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 13 \" " + absoluteSketchLocation + "\" \n " , ctx .PrototypesSection )
424423
425424 preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch_with_config" , "sketch_with_config.preprocessed.txt" ), context , ctx )
@@ -466,7 +465,7 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
466465 NoError (t , err )
467466 }
468467
469- require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , context [ constants . CTX_INCLUDE_SECTION ].( string ) )
468+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx . IncludeSection )
470469 require .Equal (t , "" , ctx .PrototypesSection )
471470}
472471
@@ -510,7 +509,7 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
510509 NoError (t , err )
511510 }
512511
513- require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , context [ constants . CTX_INCLUDE_SECTION ].( string ) )
512+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx . IncludeSection )
514513 require .Equal (t , "" , ctx .PrototypesSection )
515514}
516515
@@ -554,7 +553,7 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
554553 NoError (t , err )
555554 }
556555
557- require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , context [ constants . CTX_INCLUDE_SECTION ].( string ) )
556+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx . IncludeSection )
558557 require .Equal (t , "#line 4 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 7 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx .PrototypesSection )
559558}
560559
@@ -598,7 +597,7 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
598597 NoError (t , err )
599598 }
600599
601- require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , context [ constants . CTX_INCLUDE_SECTION ].( string ) )
600+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx . IncludeSection )
602601
603602 expected := "#line 1 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 2 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 4 \" " + absoluteSketchLocation + "\" \n short unsigned int testInt();\n #line 8 \" " + absoluteSketchLocation + "\" \n static int8_t testInline();\n #line 12 \" " + absoluteSketchLocation + "\" \n __attribute__((always_inline)) uint8_t testAttribute();\n #line 1 \" " + absoluteSketchLocation + "\" \n "
604603 obtained := ctx .PrototypesSection
@@ -653,7 +652,7 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
653652 NoError (t , err )
654653 }
655654
656- require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , context [ constants . CTX_INCLUDE_SECTION ].( string ) )
655+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx . IncludeSection )
657656 require .Equal (t , "#line 1 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 3 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 15 \" " + absoluteSketchLocation + "\" \n int8_t adalight();\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx .PrototypesSection )
658657}
659658
@@ -697,7 +696,7 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
697696 NoError (t , err )
698697 }
699698
700- require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , context [ constants . CTX_INCLUDE_SECTION ].( string ) )
699+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx . IncludeSection )
701700 require .Equal (t , "#line 5 \" " + absoluteSketchLocation + "\" \n void ciao();\n #line 10 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 15 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 5 \" " + absoluteSketchLocation + "\" \n " , ctx .PrototypesSection )
702701}
703702
@@ -740,7 +739,7 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
740739 NoError (t , err )
741740 }
742741
743- require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , context [ constants . CTX_INCLUDE_SECTION ].( string ) )
742+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx . IncludeSection )
744743 expected := "#line 6 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 10 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 12 \" " + absoluteSketchLocation + "\" \n typename Foo<char>::Bar func();\n #line 6 \" " + absoluteSketchLocation + "\" \n "
745744 obtained := ctx .PrototypesSection
746745 // ctags based preprocessing ignores line with typename
@@ -790,7 +789,7 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
790789 NoError (t , err )
791790 }
792791
793- require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , context [ constants . CTX_INCLUDE_SECTION ].( string ) )
792+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx . IncludeSection )
794793 require .Equal (t , "#line 5 \" " + absoluteSketchLocation + "\" \n void elseBranch();\n #line 9 \" " + absoluteSketchLocation + "\" \n void f1();\n #line 10 \" " + absoluteSketchLocation + "\" \n void f2();\n #line 12 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 14 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 5 \" " + absoluteSketchLocation + "\" \n " , ctx .PrototypesSection )
795794
796795 expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.txt" ), context , ctx )
@@ -837,7 +836,7 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
837836 NoError (t , err )
838837 }
839838
840- require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , context [ constants . CTX_INCLUDE_SECTION ].( string ) )
839+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx . IncludeSection )
841840 require .Equal (t , "#line 2 \" " + absoluteSketchLocation + "\" \n void ifBranch();\n #line 9 \" " + absoluteSketchLocation + "\" \n void f1();\n #line 10 \" " + absoluteSketchLocation + "\" \n void f2();\n #line 12 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 14 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 2 \" " + absoluteSketchLocation + "\" \n " , ctx .PrototypesSection )
842841
843842 expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.SAM.txt" ), context , ctx )
@@ -884,7 +883,7 @@ func TestPrototypesAdderSketchWithConst(t *testing.T) {
884883 NoError (t , err )
885884 }
886885
887- require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , context [ constants . CTX_INCLUDE_SECTION ].( string ) )
886+ require .Equal (t , "#include <Arduino.h>\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx . IncludeSection )
888887 require .Equal (t , "#line 1 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 2 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 4 \" " + absoluteSketchLocation + "\" \n const __FlashStringHelper* test();\n #line 6 \" " + absoluteSketchLocation + "\" \n const int test3();\n #line 8 \" " + absoluteSketchLocation + "\" \n volatile __FlashStringHelper* test2();\n #line 10 \" " + absoluteSketchLocation + "\" \n volatile int test4();\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx .PrototypesSection )
889888}
890889
0 commit comments