diff --git a/r5/liquid/liquid-tests.json b/r5/liquid/liquid-tests.json index 7900395b..c3007453 100644 --- a/r5/liquid/liquid-tests.json +++ b/r5/liquid/liquid-tests.json @@ -95,6 +95,11 @@ "focus" : "Patient/example", "template" : "{%for telecom in Patient.telecom reversed%}{{telecom.use}}{%endfor%}", "output" : "oldmobileworkhome" + },{ + "name" : "forsplit", + "focus" : "Patient/example", + "template" : "{% assign l = 'a,b,c' || split: ',' %}{%for s in l %}{{s}}{%endfor%}", + "output" : "abc" },{ "name" : "assign1", "focus" : "Patient/example", @@ -110,5 +115,657 @@ "focus" : "Patient/example", "template" : "{% capture my_variable %}false{%endcapture%}{% if my_variable != true %}This statement is valid.{% endif %}", "output" : "This statement is valid." - }] -} + },{ + "name" : "upcase", + "focus" : "Patient/example", + "template" : "{{ \"Parker Moore\" || upcase }}", + "output" : "PARKER MOORE" + },{ + "name" : "downcase", + "focus" : "Patient/example", + "template" : "{{ \"Parker Moore\" || downcase }}", + "output" : "parker moore" + },{ + "name" : "capitalize", + "focus" : "Patient/example", + "template" : "{{ \"my GREAT title\" || capitalize }}", + "output" : "My great title" + },{ + "name" : "replace", + "focus" : "Patient/example", + "template" : "{{ \"Take my protein pills and put my helmet on\" || replace: \"my\", \"your\" }}", + "output" : "Take your protein pills and put your helmet on" + },{ + "name" : "replace_first", + "focus" : "Patient/example", + "template" : "{{ \"Take my protein pills and put my helmet on\" || replace_first: \"my\", \"your\" }}", + "output" : "Take your protein pills and put my helmet on" + },{ + "name" : "replace_last", + "focus" : "Patient/example", + "template" : "{{ \"Take my protein pills and put my helmet on\" || replace_last: \"my\", \"your\" }}", + "output" : "Take my protein pills and put your helmet on" + },{ + "name" : "remove", + "focus" : "Patient/example", + "template" : "{{ \"I strained to see the train through the rain\" || remove: \"rain\" }}", + "output" : "I sted to see the t through the " + },{ + "name" : "remove_first", + "focus" : "Patient/example", + "template" : "{{ \"I strained to see the train through the rain\" || remove_first: \"rain\" }}", + "output" : "I sted to see the train through the rain" + },{ + "name" : "remove_last", + "focus" : "Patient/example", + "template" : "{{ \"I strained to see the train through the rain\" || remove_last: \"rain\" }}", + "output" : "I strained to see the train through the " + },{ + "name" : "date1", + "focus" : "Patient/example", + "template" : "{{ \"2015-07-17\" || date: \"%a, %b %d, %y\" }}", + "output" : "Fri, Jul 17, 15" + },{ + "name" : "date2", + "focus" : "Patient/example", + "template" : "{{ \"2015-07-17\" || date: \"%Y\" }}", + "output" : "2015" + },{ + "name" : "date3", + "focus" : "Patient/example", + "template" : "{{ \"2016-03-14\" || date: \"%b %d, %y\" }}", + "output" : "Mar 14, 16" + },{ + "name" : "date4", + "focus" : "Patient/example", + "template" : "{{ \"2015-07-17T00:46:00Z\" || date: \"%Y-%m-%d %H:%M\" }}", + "output" : "2015-07-17 00:46" + },{ + "name" : "date5", + "focus" : "Patient/example", + "template" : "{{ \"July 3, 2002\" || date: \"%Y-%m-%d\" }}", + "output" : "2002-07-03" + },{ + "name" : "date", + "focus" : "Patient/example", + "template" : "{{ \"7-3-02\" || date: \"%Y-%m-%d\" }}", + "output" : "2002-07-03" + },{ + "name" : "append", + "focus" : "Patient/example", + "template" : "{{ \"/my/fancy/url\" || append: \".html\" }}", + "output" : "/my/fancy/url.html" + },{ + "name" : "append2", + "focus" : "Patient/example", + "template" : "{{ \"Adam\" || append: \"!\" }}", + "output" : "Adam!" + },{ + "name" : "base64_encode", + "focus" : "Patient/example", + "template" : "{{ \"one two three\" || base64_encode }}", + "output" : "b25lIHR3byB0aHJlZQ==" + },{ + "name" : "base64_decode", + "focus" : "Patient/example", + "template" : "{{ \"b25lIHR3byB0aHJlZQ==\" || base64_decode }}", + "output" : "one two three" + },{ + "name" : "escape", + "focus" : "Patient/example", + "template" : "{{ \"Have you read 'James & the Giant Peach'?\" || escape }}", + "output" : "Have you read 'James & the Giant Peach'?" + },{ + "name" : "escape_once", + "focus" : "Patient/example", + "template" : "{{ \"1 < 2 & 3\" || escape_once }}", + "output" : "1 < 2 & 3" + },{ + "name" : "lstrip", + "focus" : "Patient/example", + "template" : "{{ \" So much room for activities! \" || lstrip }}", + "output" : "So much room for activities! " + },{ + "name" : "rstrip", + "focus" : "Patient/example", + "template" : "{{ \" So much room for activities! \" || rstrip }}", + "output" : " So much room for activities!" + },{ + "name" : "strip", + "focus" : "Patient/example", + "template" : "{{ \" So much room for activities! \" || strip }}", + "output" : "So much room for activities!" + },{ + "name" : "newline_to_br", + "focus" : "Patient/example", + "template" : "{{ \"Hello\nWorld\" || newline_to_br }}", + "output" : "Hello
\nWorld" + },{ + "name" : "slice1", + "focus" : "Patient/example", + "template" : "{{ \"Liquid\" || slice: 0 }}", + "output" : "L" + },{ + "name" : "slice2", + "focus" : "Patient/example", + "template" : "{{ \"Liquid\" || slice: 2 }}", + "output" : "q" + },{ + "name" : "slice3", + "focus" : "Patient/example", + "template" : "{{ \"Liquid\" || slice: 2, 5 }}", + "output" : "quid" + },{ + "name" : "slice_negative", + "focus" : "Patient/example", + "template" : "{{ \"Liquid\" || slice: -3, 2 }}", + "output" : "ui" + },{ + "name" : "strip_html", + "focus" : "Patient/example", + "template" : "{{ \"Have you read Erta?\" || strip_html }}", + "output" : "Have you read Erta?" + },{ + "name" : "strip_newlines", + "focus" : "Patient/example", + "template" : "{{ \"Hello\nthere\" || strip_newlines }}", + "output" : "Hellothere" + },{ + "name" : "truncate1", + "focus" : "Patient/example", + "template" : "{{ \"Ground control to Major Tom.\" || truncate: 20 }}", + "output" : "Ground control to..." + },{ + "name" : "truncate2", + "focus" : "Patient/example", + "template" : "{{ \"Ground control to Major Tom.\" || truncate: 25, \", and so on\" }}", + "output" : "Ground control, and so on" + },{ + "name" : "truncate3", + "focus" : "Patient/example", + "template" : "{{ \"Ground control to Major Tom.\" || truncate: 20, \"\" }}", + "output" : "Ground control to Ma" + },{ + "name" : "truncatewords1", + "focus" : "Patient/example", + "template" : "{{ \"Ground control to Major Tom.\" || truncatewords: 3 }}", + "output" : "Ground control to..." + },{ + "name" : "truncatewords2", + "focus" : "Patient/example", + "template" : "{{ \"Ground control to Major Tom.\" || truncatewords: 3, \"---\" }}", + "output" : "Ground control to---" + },{ + "name" : "truncatewords3", + "focus" : "Patient/example", + "template" : "{{ \"Ground control to Major Tom.\" || truncatewords: 3, \"\" }}", + "output" : "Ground control to" + },{ + "name" : "url_encode", + "focus" : "Patient/example", + "template" : "{{ \"john@liquid.com\" || url_encode }}", + "output" : "john%40liquid.com" + },{ + "name" : "url_encode2", + "focus" : "Patient/example", + "template" : "{{ \"Tetsuro Takara\" || url_encode }}", + "output" : "Tetsuro+Takara" + },{ + "name" : "url_decode", + "focus" : "Patient/example", + "template" : "{{ \"%27Stop%21%27+said+Fred\" || url_decode }}", + "output" : "'Stop!' said Fred" + },{ + "name" : "url_decode2", + "focus" : "Patient/example", + "template" : "{{ \"rain+100%25\" || url_decode }}", + "output" : "rain 100%" + },{ + "name" : "abs1", + "focus" : "Patient/example", + "template" : "{{ \"-17\" || abs }}", + "output" : "17" + },{ + "name" : "abs2", + "focus" : "Patient/example", + "template" : "{{ \"4\" || abs }}", + "output" : "4" + },{ + "name" : "abs3", + "focus" : "Patient/example", + "template" : "{{ \"-19.86\" || abs }}", + "output" : "19.86" + },{ + "name" : "at_least1", + "focus" : "Patient/example", + "template" : "{{ \"4\" || at_least: 5 }}", + "output" : "5" + },{ + "name" : "at_least2", + "focus" : "Patient/example", + "template" : "{{ \"4\" || at_least: 3 }}", + "output" : "4" + },{ + "name" : "at_most1", + "focus" : "Patient/example", + "template" : "{{ \"4\" || at_most: 5 }}", + "output" : "4" + },{ + "name" : "at_most2", + "focus" : "Patient/example", + "template" : "{{ \"4\" || at_most: 3 }}", + "output" : "3" + },{ + "name" : "ceil1", + "focus" : "Patient/example", + "template" : "{{ \"1.2\" || ceil }}", + "output" : "2" + },{ + "name" : "ceil2", + "focus" : "Patient/example", + "template" : "{{ \"2.0\" || ceil }}", + "output" : "2" + },{ + "name" : "ceil3", + "focus" : "Patient/example", + "template" : "{{ \"183.357\" || ceil }}", + "output" : "184" + },{ + "name" : "divided_by1", + "focus" : "Patient/example", + "template" : "{{ \"16\" || divided_by: 4 }}", + "output" : "4" + },{ + "name" : "divided_by2", + "focus" : "Patient/example", + "template" : "{{ \"5\" || divided_by: 3 }}", + "output" : "1" + },{ + "name" : "divided_by3", + "focus" : "Patient/example", + "template" : "{{ \"20\" || divided_by: 7.0 }}", + "output" : "2.857142857142857" + },{ + "name" : "floor1", + "focus" : "Patient/example", + "template" : "{{ \"1.2\" || floor }}", + "output" : "1" + },{ + "name" : "floor2", + "focus" : "Patient/example", + "template" : "{{ \"2.0\" || floor }}", + "output" : "2" + },{ + "name" : "floor3", + "focus" : "Patient/example", + "template" : "{{ \"183.357\" || floor }}", + "output" : "183" + },{ + "name" : "minus1", + "focus" : "Patient/example", + "template" : "{{ \"4\" || minus: 2 }}", + "output" : "2" + },{ + "name" : "minus2", + "focus" : "Patient/example", + "template" : "{{ \"16\" || minus: 4 }}", + "output" : "12" + },{ + "name" : "minus3", + "focus" : "Patient/example", + "template" : "{{ \"183.357\" || minus: 12 }}", + "output" : "171.357" + },{ + "name" : "modulo1", + "focus" : "Patient/example", + "template" : "{{ \"3\" || modulo: 2 }}", + "output" : "1" + },{ + "name" : "modulo2", + "focus" : "Patient/example", + "template" : "{{ \"24\" || modulo: 7 }}", + "output" : "3" + },{ + "name" : "modulo3", + "focus" : "Patient/example", + "template" : "{{ \"183.357\" || modulo: 12 }}", + "output" : "3.3569999999999993" + },{ + "name" : "plus1", + "focus" : "Patient/example", + "template" : "{{ \"4\" || plus: 2 }}", + "output" : "6" + },{ + "name" : "plus2", + "focus" : "Patient/example", + "template" : "{{ \"16\" || plus: 4 }}", + "output" : "20" + },{ + "name" : "plus3", + "focus" : "Patient/example", + "template" : "{{ \"183.357\" || plus: 12 }}", + "output" : "195.357" + },{ + "name" : "round1", + "focus" : "Patient/example", + "template" : "{{ \"1.2\" || round }}", + "output" : "1" + },{ + "name" : "round2", + "focus" : "Patient/example", + "template" : "{{ \"2.7\" || round }}", + "output" : "3" + },{ + "name" : "round3", + "focus" : "Patient/example", + "template" : "{{ \"183.357\" || round: 2 }}", + "output" : "183.36" + },{ + "name" : "times1", + "focus" : "Patient/example", + "template" : "{{ \"3\" || times: 2 }}", + "output" : "6" + },{ + "name" : "times2", + "focus" : "Patient/example", + "template" : "{{ \"24\" || times: 7 }}", + "output" : "168" + },{ + "name" : "times3", + "focus" : "Patient/example", + "template" : "{{ \"183.357\" || times: 12 }}", + "output" : "2200.284" + },{ + "name" : "first", + "focus" : "Patient/example", + "template" : "{{ \"John, Paul, George, Ringo\" || split: \", \" || first }}", + "output" : "John" + },{ + "name" : "last", + "focus" : "Patient/example", + "template" : "{{ \"John, Paul, George, Ringo\" || split: \", \" || last }}", + "output" : "Ringo" + },{ + "name" : "join", + "focus" : "Patient/example", + "template" : "{{ \"John, Paul, George, Ringo\" || split: \", \" || join: \" and \" }}", + "output" : "John and Paul and George and Ringo" + },{ + "name" : "reverse", + "focus" : "Patient/example", + "template" : "{{ \"John, Paul, George, Ringo\" || split: \", \" || reverse || join: \", \" }}", + "output" : "Ringo, George, Paul, John" + },{ + "name" : "size_string", + "focus" : "Patient/example", + "template" : "{{ \"Ground control to Major Tom.\" || size }}", + "output" : "28" + },{ + "name" : "size_array", + "focus" : "Patient/example", + "template" : "{{ \"John, Paul, George, Ringo\" || split: \", \" || size }}", + "output" : "4" + },{ + "name" : "sort", + "focus" : "Patient/example", + "template" : "{{ \"zebra, octopus, giraffe, Sally Snake\" || split: \", \" || sort || join: \", \" }}", + "output" : "Sally Snake, giraffe, octopus, zebra" + },{ + "name" : "sort_natural", + "focus" : "Patient/example", + "template" : "{{ \"zebra, octopus, giraffe, Sally Snake\" || split: \", \" || sort_natural || join: \", \" }}", + "output" : "giraffe, octopus, Sally Snake, zebra" + },{ + "name" : "uniq", + "focus" : "Patient/example", + "template" : "{{ \"ants, bugs, bees, bugs, ants\" || split: \", \" || uniq || join: \", \" }}", + "output" : "ants, bugs, bees" + },{ + "name" : "compact", + "focus" : "Patient/example", + "template" : "{{ \"a,,b,,c\" || split: \",\" || compact || join: \", \" }}", + "output" : "a, b, c" + },{ + "name" : "concat", + "focus" : "Patient/example", + "template" : "{% assign fruits = \"apples, oranges\" || split: \", \" %}{% assign vegetables = \"carrots, turnips\" || split: \", \" %}{% assign everything = fruits || concat: vegetables %}{{ everything || join: \", \" }}", + "output" : "apples, oranges, carrots, turnips" + },{ + "name" : "sum", + "focus" : "Patient/example", + "template" : "{{ \"1,2,3\" || split: \",\" || sum }}", + "output" : "6" + },{ + "name" : "default1", + "focus" : "Patient/example", + "template" : "{{ \"\" || default: \"default value\" }}", + "output" : "default value" + },{ + "name" : "default2", + "focus" : "Patient/example", + "template" : "{{ \"hello\" || default: \"default value\" }}", + "output" : "hello" + },{ + "name" : "json", + "focus" : "Patient/example", + "template" : "{{ \"hello world\" || json }}", + "output" : "\"hello world\"" + },{ + "name" : "split1", + "focus" : "Patient/example", + "template" : "{{ \"Hi, how are you today?\" || split: \" \" || size }}", + "output" : "5" + },{ + "name" : "slice_neg_single", + "focus" : "Patient/example", + "template" : "{{ \"Liquid\" || slice: -3 }}", + "output" : "u" + },{ + "name" : "strip_html2", + "focus" : "Patient/example", + "template" : "{{ \"text\" || strip_html }}", + "output" : "alert('hi')text" + },{ + "name" : "truncate_noop", + "focus" : "Patient/example", + "template" : "{{ \"Hi\" || truncate: 20 }}", + "output" : "Hi" + },{ + "name" : "escape2", + "focus" : "Patient/example", + "template" : "{{ \"

test

\" || escape }}", + "output" : "<p>test</p>" + },{ + "name" : "append_chain", + "focus" : "Patient/example", + "template" : "{{ \"liq\" || append: \"uid\" }}", + "output" : "liquid" + },{ + "name" : "base64_roundtrip", + "focus" : "Patient/example", + "template" : "{{ \"abc\" || base64_encode || base64_decode }}", + "output" : "abc" + },{ + "name" : "plus_float", + "focus" : "Patient/example", + "template" : "{{ \"183.357\" || plus: 12.5 }}", + "output" : "195.857" + },{ + "name" : "minus_negative", + "focus" : "Patient/example", + "template" : "{{ \"4\" || minus: 6 }}", + "output" : "-2" + },{ + "name" : "divided_by_float_result", + "focus" : "Patient/example", + "template" : "{{ \"20\" || divided_by: 7 }}", + "output" : "2" + },{ + "name" : "times_float", + "focus" : "Patient/example", + "template" : "{{ \"5\" || times: 1.1 }}", + "output" : "5.5" + },{ + "name" : "round4", + "focus" : "Patient/example", + "template" : "{{ \"1.5\" || round }}", + "output" : "2" + },{ + "name" : "size_empty", + "focus" : "Patient/example", + "template" : "{{ \"\" || size }}", + "output" : "0" + },{ + "name" : "reverse_string", + "focus" : "Patient/example", + "template" : "{{ \"abc\" || split: \"\" || reverse || join: \"\" }}", + "output" : "cba" + },{ + "name" : "json_special", + "focus" : "Patient/example", + "template" : "{{ \"hello \\\"world\\\"\" || json }}", + "output" : "\"hello \\\"world\\\"\"" + },{ + "name" : "downcase_upcase_chain", + "focus" : "Patient/example", + "template" : "{{ \"Parker Moore\" || downcase || upcase }}", + "output" : "PARKER MOORE" + },{ + "name" : "strip_prepend", + "focus" : "Patient/example", + "template" : "{{ \" hello \" || strip || prepend: \"[\" || append: \"]\" }}", + "output" : "[hello]" + },{ + "name" : "remove_literal_regex_chars", + "focus" : "Patient/example", + "template" : "{{ \"a+b+c+\" || remove: \"+\" }}", + "output" : "abc" + },{ + "name" : "remove_first_literal_regex_chars", + "focus" : "Patient/example", + "template" : "{{ \"a+b+c+\" || remove_first: \"+\" }}", + "output" : "ab+c+" + },{ + "name" : "default_whitespace_non_empty", + "focus" : "Patient/example", + "template" : "{{ \" \" || default: \"fallback\" }}", + "output" : " " + },{ + "name" : "date_iso_local_datetime", + "focus" : "Patient/example", + "template" : "{{ \"2015-07-17T00:46:00\" || date: \"%Y-%m-%d %H:%M\" }}", + "output" : "2015-07-17 00:46" + },{ + "name" : "map_unsupported", + "focus" : "Patient/example", + "template" : "{{ \"a,b\" || split: \",\" || map: \"value\" }}", + "error" : true + },{ + "name" : "where_unsupported", + "focus" : "Patient/example", + "template" : "{{ \"a,b\" || split: \",\" || where: \"value\", \"a\" }}", + "error" : true + },{ + "name" : "date_unparseable_value_throws", + "focus" : "Patient/example", + "template" : "{{ \"not a date\" || date: \"%Y-%m-%d\" }}", + "error" : true + },{ + "name" : "unknown_filter_throws", + "focus" : "Patient/example", + "template" : "{{ \"hello\" || notafilter }}", + "error" : true + },{ + "name" : "unknown_syntax_after_pipe_throws", + "focus" : "Patient/example", + "template" : "{{ \"hello\" || upcase xyz }}", + "error" : true + },{ + "name" : "invalid_fhirpath_expression_throws", + "focus" : "Patient/example", + "template" : "{{ @@invalid }}", + "error" : true + },{ + "name" : "unclosed_statement_tag_throws", + "focus" : "Patient/example", + "template" : "{{ Patient.id ", + "error" : true + },{ + "name" : "unclosed_block_tag_throws", + "focus" : "Patient/example", + "template" : "{% if Patient.id = 'example' %} yes ", + "error" : true + },{ + "name" : "missing_endif_throws", + "focus" : "Patient/example", + "template" : "{% if Patient.id = 'example' %}yes{% endfor %}", + "error" : true + },{ + "name" : "missing_endfor_throws", + "focus" : "Patient/example", + "template" : "{%for name in Patient.name%}{{name.family}}", + "error" : true + },{ + "name" : "for_loop_missing_in_throws", + "focus" : "Patient/example", + "template" : "{%for name of Patient.name%}{{name.family}}{%endfor%}", + "error" : true + },{ + "name" : "for_loop_illegal_varname_throws", + "focus" : "Patient/example", + "template" : "{%for include in Patient.name%}{{include.family}}{%endfor%}", + "error" : true + },{ + "name" : "for_loop_limit_missing_colon_throws", + "focus" : "Patient/example", + "template" : "{%for telecom in Patient.telecom limit 2%}{{telecom.use}}{%endfor%}", + "error" : true + },{ + "name" : "for_loop_limit_missing_number_throws", + "focus" : "Patient/example", + "template" : "{%for telecom in Patient.telecom limit:x%}{{telecom.use}}{%endfor%}", + "error" : true + },{ + "name" : "for_loop_offset_missing_colon_throws", + "focus" : "Patient/example", + "template" : "{%for telecom in Patient.telecom offset 2%}{{telecom.use}}{%endfor%}", + "error" : true + },{ + "name" : "for_loop_offset_missing_number_throws", + "focus" : "Patient/example", + "template" : "{%for telecom in Patient.telecom offset:x%}{{telecom.use}}{%endfor%}", + "error" : true + },{ + "name" : "for_loop_unknown_modifier_throws", + "focus" : "Patient/example", + "template" : "{%for telecom in Patient.telecom backwards%}{{telecom.use}}{%endfor%}", + "error" : true + },{ + "name" : "unknown_flow_statement_throws", + "focus" : "Patient/example", + "template" : "{% unknown something %}", + "error" : true + },{ + "name" : "include_no_resolver_throws", + "focus" : "Patient/example", + "template" : "{%include missing.html%}", + "error" : true + },{ + "name" : "include_not_resolved_throws", + "focus" : "Patient/example", + "template" : "{%loop name in Patient.name%}{%include notfound.html name=name%}{%endloop%}", + "error" : true, + "includes" : {} + },{ + "name" : "date_no_timezone_uses_local_zone_output_regex", + "focus" : "Patient/example", + "template" : "{{ \"2015-07-17T00:46:00\" || date: \"%Y-%m-%d %H:%M %z\" }}", + "outputRegex" : "^2015-07-17 00:46 [+-][0-9]{4}$" + },{ + "name" : "date_explicit_offset_preserved_output_regex", + "focus" : "Patient/example", + "template" : "{{ \"2015-07-17T00:46:00+02:00\" || date: \"%Y-%m-%d %H:%M %z\" }}", + "outputRegex" : "^2015-07-17 00:46 \\+0200$" + } + ] +} \ No newline at end of file