Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[t/hitomi] added three more test files

They cover variable substitution, if statements, and for loops. The exact
type names and calling conventions are still not set in stone.
  • Loading branch information...
commit 6918b4ee73ac2ca57302cadedf88c541ef56ec3a 1 parent 56156ff
Carl Mäsak authored June 01, 2009
31  t/hitomi/02-substitution.t
... ...
@@ -0,0 +1,31 @@
  1
+use v6;
  2
+use Test;
  3
+use Hitomi;
  4
+
  5
+plan 2;
  6
+
  7
+{
  8
+    my Hitomi::MarkupTemplate $template .= new('<html>
  9
+  <h1>Hello, $name!</h1>
  10
+</html>
  11
+');
  12
+    my Hitomi::Stream $stream = $template.generate( :name<world> );
  13
+    is $stream.render('html', :doctype(Hitomi::DocType::HTML5)),
  14
+       '<!DOCTYPE html>
  15
+<html>
  16
+  <h1>Hello, world!</h1>
  17
+</html>
  18
+', 'simple variable substitution works';
  19
+}
  20
+
  21
+{
  22
+    my Hitomi::MarkupTemplate $template .= new('<html>
  23
+  <h1>Hello, ${ $name }</h1></html>
  24
+');
  25
+    my Hitomi::Stream $stream = $template.generate( :name<world> );
  26
+    is $stream.render('html', :doctype(Hitomi::DocType::HTML5)),       '<!DOCTYPE html>
  27
+<html>
  28
+  <h1>Hello, world!</h1>
  29
+</html>
  30
+', 'dollar block substitution works';
  31
+}
25  t/hitomi/03-if.t
... ...
@@ -0,0 +1,25 @@
  1
+use v6;
  2
+use Test;
  3
+use Hitomi;
  4
+
  5
+plan 2;
  6
+
  7
+{
  8
+    my Hitomi::MarkupTemplate $template .= new('<html>
  9
+  <h1 pe:if="$flag">Hello, world!</h1>
  10
+</html>
  11
+');
  12
+    is $template.generate( :flag(True) ).render('html',
  13
+                           :doctype(Hitomi::DocType::HTML5)),
  14
+       '<!DOCTYPE html>
  15
+<html>
  16
+  <h1>Hello, world!</h1>
  17
+</html>
  18
+', 'true if statement works';
  19
+    is $template.generate( :flag(False) ).render('html',
  20
+                           :doctype(Hitomi::DocType::HTML5)),
  21
+       '<!DOCTYPE html>
  22
+<html>
  23
+</html>
  24
+', 'false if statement works';
  25
+}
37  t/hitomi/04-for.t
... ...
@@ -0,0 +1,37 @@
  1
+use v6;
  2
+use Test;
  3
+use Hitomi;
  4
+
  5
+plan 2;
  6
+
  7
+{
  8
+    my Hitomi::MarkupTemplate $template .= new('<html>
  9
+  <h1 pe:for="@list">$_</h1>
  10
+</html>
  11
+');
  12
+    is $template.generate( '@list' => <foo bar baz> ).render('html',
  13
+                           :doctype(Hitomi::DocType::HTML5)),
  14
+       '<!DOCTYPE html>
  15
+<html>
  16
+  <h1>foo</h1>
  17
+  <h1>bar</h1>
  18
+  <h1>baz</h1>
  19
+</html>
  20
+', 'for loop with loop variable $_ works';
  21
+}
  22
+
  23
+{
  24
+    my Hitomi::MarkupTemplate $template .= new('<html>
  25
+  <h1 pe:for="@list -> $item">$item</h1>
  26
+</html>
  27
+');
  28
+    is $template.generate( '@list' => <foo bar baz> ).render('html',
  29
+                           :doctype(Hitomi::DocType::HTML5)),
  30
+       '<!DOCTYPE html>
  31
+<html>
  32
+  <h1>foo</h1>
  33
+  <h1>bar</h1>
  34
+  <h1>baz</h1>
  35
+</html>
  36
+', 'for loop with custom loop variable works';
  37
+}

0 notes on commit 6918b4e

Please sign in to comment.
Something went wrong with that request. Please try again.