Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 81 lines (69 sloc) 1.754 kb
d289faf2 »
2008-10-09 Import of Amrita 1.0.2
1 require 'runit/testcase'
2 require 'amrita/ams.rb'
3
4 class TestAms < RUNIT::TestCase
5 include Amrita
6 include HtmlCompiler
7
8 def test_ams1
9 tempfile = "/tmp/amritatest#{$$}"
10 File.open(tempfile, "w") { |f| f.print <<-END }
11 <AmritaScript> <!--
12 data = {
13 :a => "ams test"
14 }
15 //--></AmritaScript>
16 <p id="a">sample_text</p>
17 END
18
19 t = AmsTemplate.new(tempfile)
20 result = ""
21 t.expand(result)
22 assert_equal(" <p>ams test</p>\n", result)
23 ensure
24 #File.open(tempfile) { |f| puts f.read }
25 File::unlink(tempfile)
26 end
27
28 def test_ams2
29 tempfile = "/tmp/amritatest#{$$}"
30 File.open(tempfile, "w") { |f| f.print <<-END }
31 <AmritaScript type="module"> <!--
32 def a
33 "ams test module type"
34 end
35 //--></AmritaScript>
36 <p id="a">sample_text</p>
37 END
38
39 t = AmsTemplate.new(tempfile)
40 result = ""
41 t.expand(result)
42 assert_equal(" <p>ams test module type</p>\n", result)
43 ensure
44 #File.open(tempfile) { |f| puts f.read }
45 File::unlink(tempfile)
46 end
47
48 def test_yaml1
49 tempfile = "/tmp/amritatest#{$$}"
50 File.open(tempfile, "w") { |f| f.print <<-END }
51 <AmritaScript type="yaml"> <!--
52 a: "ams test"
53 //--></AmritaScript>
54 <p id="a">sample_text</p>
55 END
56
57 t = AmsTemplate.new(tempfile)
58 result = ""
59 t.expand(result)
60 assert_equal(" <p>ams test</p>\n", result)
61 ensure
62 #File.open(tempfile) { |f| puts f.read }
63 File::unlink(tempfile)
64 end
65
66 end
67
68
69 #--- main program ----
70 if __FILE__ == $0
71 require 'runit/cui/testrunner'
72 if ARGV.size == 0
73 RUNIT::CUI::TestRunner.run(TestAms.suite)
74 else
75 ARGV.each do |method|
76 RUNIT::CUI::TestRunner.run(TestAms.new(method))
77 end
78 end
79 end
80
Something went wrong with that request. Please try again.