-
-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathgenerator_macros.j2
More file actions
41 lines (33 loc) · 1.25 KB
/
generator_macros.j2
File metadata and controls
41 lines (33 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{# Usage: {%- import "generator_macros.j2" as macros -%} #}
{# {{ macros.linebreak(text) }} #}
{%- macro linebreak(s) %}
{%- set parts = s.split(": ") -%}
"{{ parts[0] }}: "
{% for part in parts[1].split(", ") %}
"{{ part }}{% if not loop.last %}, {% endif %}"
{%- endfor %}
{% endmacro -%}
{% macro canonical_ref() -%}
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/{{ exercise }}/canonical-data.json
# File last updated on {{ current_date }}
{%- endmacro %}
{% macro header(ignore=[]) -%}
source("./{{ exercise }}.R")
library(testthat)
{%- endmacro %}
{#We need to figure out what the error message and checking look like for R#}
{#Then we can modify this macro so it works#}
{#see https://stackoverflow.com/questions/55667491/how-to-test-for-an-error-and-specific-error-message-using-testthat-in-r#}
{#for more info#}
{#{% macro utility() -%}# Utility functions#}
{# def assertRaisesWithMessage(self, exception):#}
{# return self.assertRaisesRegex(exception, r".+")#}
{#{%- endmacro %}#}
{% macro empty_set(set, list, class_name) -%}
{%- if list|length > 0 -%}
{{ set }} = {{ class_name }}({{ list }})
{%- else -%}
{{ set }} = {{ class_name }}()
{%- endif %}
{%- endmacro %}