@@ -32,7 +32,6 @@ package test
32
32
33
33
import (
34
34
"arduino.cc/builder"
35
- "arduino.cc/builder/constants"
36
35
"arduino.cc/builder/types"
37
36
"github.com/stretchr/testify/require"
38
37
"os"
@@ -83,7 +82,7 @@ func TestPrototypesAdderBridgeExample(t *testing.T) {
83
82
NoError (t , err )
84
83
}
85
84
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 )
87
86
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 )
88
87
}
89
88
@@ -419,7 +418,7 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
419
418
NoError (t , err )
420
419
}
421
420
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 )
423
422
require .Equal (t , "#line 13 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 17 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 13 \" " + absoluteSketchLocation + "\" \n " , ctx .PrototypesSection )
424
423
425
424
preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch_with_config" , "sketch_with_config.preprocessed.txt" ), context , ctx )
@@ -466,7 +465,7 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
466
465
NoError (t , err )
467
466
}
468
467
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 )
470
469
require .Equal (t , "" , ctx .PrototypesSection )
471
470
}
472
471
@@ -510,7 +509,7 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
510
509
NoError (t , err )
511
510
}
512
511
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 )
514
513
require .Equal (t , "" , ctx .PrototypesSection )
515
514
}
516
515
@@ -554,7 +553,7 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
554
553
NoError (t , err )
555
554
}
556
555
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 )
558
557
require .Equal (t , "#line 4 \" " + absoluteSketchLocation + "\" \n void setup();\n #line 7 \" " + absoluteSketchLocation + "\" \n void loop();\n #line 1 \" " + absoluteSketchLocation + "\" \n " , ctx .PrototypesSection )
559
558
}
560
559
@@ -598,7 +597,7 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
598
597
NoError (t , err )
599
598
}
600
599
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 )
602
601
603
602
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 "
604
603
obtained := ctx .PrototypesSection
@@ -653,7 +652,7 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
653
652
NoError (t , err )
654
653
}
655
654
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 )
657
656
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 )
658
657
}
659
658
@@ -697,7 +696,7 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
697
696
NoError (t , err )
698
697
}
699
698
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 )
701
700
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 )
702
701
}
703
702
@@ -740,7 +739,7 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
740
739
NoError (t , err )
741
740
}
742
741
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 )
744
743
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 "
745
744
obtained := ctx .PrototypesSection
746
745
// ctags based preprocessing ignores line with typename
@@ -790,7 +789,7 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
790
789
NoError (t , err )
791
790
}
792
791
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 )
794
793
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 )
795
794
796
795
expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.txt" ), context , ctx )
@@ -837,7 +836,7 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
837
836
NoError (t , err )
838
837
}
839
838
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 )
841
840
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 )
842
841
843
842
expectedSource := LoadAndInterpolate (t , filepath .Join ("sketch_with_ifdef" , "sketch.preprocessed.SAM.txt" ), context , ctx )
@@ -884,7 +883,7 @@ func TestPrototypesAdderSketchWithConst(t *testing.T) {
884
883
NoError (t , err )
885
884
}
886
885
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 )
888
887
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 )
889
888
}
890
889
0 commit comments