1 module tests.statements.include_; 2 3 private 4 { 5 import tests.asserts; 6 } 7 8 9 // Basic includes 10 unittest 11 { 12 // Include raw data file 13 assertRender( 14 `{% include "./tests/files/raw.txt" %}` 15 , 16 "RAWDATA" 17 ); 18 19 // Ignore missing file 20 assertRender( 21 `{% include "notexisting.txt" ignore missing %}` 22 , 23 "" 24 ); 25 26 // Include first exists file 27 assertRender( 28 `{% include ["notexisting.txt", "./tests/files/raw.txt"] %}` 29 , 30 "RAWDATA" 31 ); 32 33 // Include first exists file or ignore if all missing 34 assertRender( 35 `{% include ["notexisting1.txt", "notexisting2.txt"] ignore missing %}` 36 , 37 "" 38 ); 39 } 40 41 42 // Exception cases 43 unittest 44 { 45 // Include non-existing files 46 assertException(`{% include "notexisting.txt" %}`); 47 assertException(`{% include ["notexisting1.txt", "notexisting2.txt"] %}`); 48 } 49 50 51 // Context bahavior 52 unittest 53 { 54 // Include with context by default 55 assertRender( 56 `{% set a = 10 %}` ~ 57 `{% include "./tests/files/context.dj" %}` 58 , 59 "10" 60 ); 61 62 // Include with context manually 63 assertRender( 64 `{% set a = 10 %}` ~ 65 `{% include "./tests/files/context.dj" with context %}` 66 , 67 "10" 68 ); 69 70 // Include without context manually 71 assertRender( 72 `{% set a = 10 %}` ~ 73 `{% include "./tests/files/context.dj" without context %}` 74 , 75 "" 76 ); 77 }