Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 37 lines (30 sloc) 0.766 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
;; test_templates.nu
;; tests for Nu code templates.
;;
;; Copyright (c) 2007 Tim Burks, Radtastical Inc.

(load "template")

(class TestTemplates is NuTestCase
     
     (- (id) testCodeSubstitution is
        (set template (NuTemplate codeForString:<<-END
this is <%= (- 2 1) %> of many (at least <%= (+ -2 3) %>) tests.END))
        (set goal <<-END
this is 1 of many (at least 1) tests.END)
        (assert_equal goal (eval template)))
     
     (- (id) testCountingSubstitution is
        (set template (NuTemplate codeForString:<<-END
<% (10 times: (do (i) %><%= i %>: <%= (- 10 i) %>
<% )) %>END))
        (set goal <<-END
0: 10
1: 9
2: 8
3: 7
4: 6
5: 5
6: 4
7: 3
8: 2
9: 1
END)
        (set result (eval template))
        (assert_equal goal result)))


Something went wrong with that request. Please try again.