diff --git a/src/arduino.cc/builder/test/ctags_runner_test.go b/src/arduino.cc/builder/test/ctags_runner_test.go index ab75fed3..d5a26a6d 100644 --- a/src/arduino.cc/builder/test/ctags_runner_test.go +++ b/src/arduino.cc/builder/test/ctags_runner_test.go @@ -231,3 +231,47 @@ func TestCTagsRunnerSketchWithNamespace(t *testing.T) { require.Equal(t, expectedOutput, strings.Replace(context[constants.CTX_CTAGS_OUTPUT].(string), "\r\n", "\n", -1)) } + +func TestCTagsRunnerSketchWithTemplates(t *testing.T) { + DownloadCoresAndToolsAndLibraries(t) + + context := make(map[string]interface{}) + + buildPath := SetupBuildPath(t, context) + defer os.RemoveAll(buildPath) + + sketchLocation := Abs(t, filepath.Join("sketch_with_templates_and_shift", "template_and_shift.cpp")) + context[constants.CTX_HARDWARE_FOLDERS] = []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"} + context[constants.CTX_TOOLS_FOLDERS] = []string{"downloaded_tools"} + context[constants.CTX_FQBN] = "arduino:avr:leonardo" + context[constants.CTX_SKETCH_LOCATION] = sketchLocation + context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = "10600" + context[constants.CTX_BUILT_IN_LIBRARIES_FOLDERS] = []string{"downloaded_libraries"} + context[constants.CTX_OTHER_LIBRARIES_FOLDERS] = []string{"libraries"} + context[constants.CTX_VERBOSE] = true + + commands := []types.Command{ + &builder.SetupHumanLoggerIfMissing{}, + + &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, + + &builder.ContainerMergeCopySketchFiles{}, + + &builder.ContainerFindIncludes{}, + + &builder.PrintUsedLibrariesIfVerbose{}, + &builder.WarnAboutArchIncompatibleLibraries{}, + &builder.CTagsTargetFileSaver{SourceField: constants.CTX_SOURCE, TargetFileName: constants.FILE_CTAGS_TARGET}, + &ctags.CTagsRunner{}, + } + + for _, command := range commands { + err := command.Run(context) + NoError(t, err) + } + + sketchLocation = strings.Replace(sketchLocation, "\\", "\\\\", -1) + expectedOutput := "printGyro\t" + sketchLocation + "\t/^void printGyro()$/;\"\tkind:function\tline:10\tsignature:()\treturntype:void\n" + + require.Equal(t, expectedOutput, strings.Replace(context[constants.CTX_CTAGS_OUTPUT].(string), "\r\n", "\n", -1)) +} diff --git a/src/arduino.cc/builder/test/helper_tools_downloader.go b/src/arduino.cc/builder/test/helper_tools_downloader.go index 1e449e41..e8df4e20 100644 --- a/src/arduino.cc/builder/test/helper_tools_downloader.go +++ b/src/arduino.cc/builder/test/helper_tools_downloader.go @@ -138,6 +138,7 @@ func DownloadCoresAndToolsAndLibraries(t *testing.T) { Library{Name: "CapacitiveSensor", Version: "0.5.0", VersionInLibProperties: "0.5"}, Library{Name: "Ethernet", Version: "1.1.1"}, Library{Name: "Robot IR Remote", Version: "1.0.2"}, + Library{Name: "FastLED", Version: "3.1.0"}, } download(t, cores, boardsManagerCores, boardsManagerRedBearCores, tools, toolsMultipleVersions, boardsManagerTools, boardsManagerRFduinoTools, libraries) diff --git a/src/arduino.cc/builder/test/sketch11/sketch_fastleds.ino b/src/arduino.cc/builder/test/sketch11/sketch_fastleds.ino new file mode 100644 index 00000000..eba4f526 --- /dev/null +++ b/src/arduino.cc/builder/test/sketch11/sketch_fastleds.ino @@ -0,0 +1,27 @@ +#include "FastLED.h" + +#define DATA_PIN 7 +#define CLK_PIN 6 +#define LED_TYPE APA102 +#define COLOR_ORDER GRB +#define NUM_LEDS 79 +CRGB leds[NUM_LEDS]; + +#define BRIGHTNESS 96 +#define FRAMES_PER_SECOND 120 +void setup() { + + FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); +} + +void loop() { + +} + +typedef void (*SimplePatternList[])(); +//SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm }; +SimplePatternList gPatterns = {sinelon}; + +void sinelon() +{ +} \ No newline at end of file diff --git a/src/arduino.cc/builder/test/sketch_with_templates_and_shift/template_and_shift.cpp b/src/arduino.cc/builder/test/sketch_with_templates_and_shift/template_and_shift.cpp new file mode 100644 index 00000000..ce9bb444 --- /dev/null +++ b/src/arduino.cc/builder/test/sketch_with_templates_and_shift/template_and_shift.cpp @@ -0,0 +1,12 @@ +template<> class FastPin<0> : public _ARMPIN<0, 10, 1 << 10, 0> {};; + +template<> class FastPin<0> : public _ARMPIN<0, 10, 1 < 10, 0> {};; + +template class OtherType> class NestedTemplateClass +{ + OtherType f; +}; + +void printGyro() +{ +} diff --git a/src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go b/src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go index 83f5bddc..08eccaf1 100644 --- a/src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go +++ b/src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go @@ -185,6 +185,12 @@ func TestTryBuild035(t *testing.T) { tryBuild(t, "sketch_with_enum_class", "sketch_with_enum_class.ino") } +func TestTryBuild036(t *testing.T) { + context := makeDefaultContext(t) + context[constants.CTX_FQBN] = "arduino:samd:arduino_zero_native" + tryBuildWithContext(t, context, "sketch11", "sketch_fastleds.ino") +} + func makeDefaultContext(t *testing.T) map[string]interface{} { DownloadCoresAndToolsAndLibraries(t)