This repository has been archived by the owner on Oct 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic tests and some code which accidentally passes them
- Loading branch information
Tadeusz Sośnierz
committed
Sep 15, 2012
1 parent
38f666a
commit fa5e4b6
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module BreakDancer; | ||
use Shell::Command; | ||
|
||
my $basedir = 'www'; | ||
|
||
multi gen($path, &code) is export { | ||
mkpath "$basedir/$path"; | ||
given open("$basedir/$path/index.htm", :w) { | ||
.say: &code(); | ||
.close; | ||
} | ||
} | ||
|
||
multi gen($path is copy, %args, &code) is export { | ||
mkpath "$basedir/$path"; | ||
for %args.kv -> $k, $v { | ||
my $p = "$basedir/$path/$k"; | ||
mkpath $p; | ||
given open("$p/index.htm", :w) { | ||
.say: &code($k, $v); | ||
.close; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use v6; | ||
use BreakDancer; | ||
use Test; | ||
use Shell::Command; | ||
|
||
my %modules = | ||
foo => [1, 'asd'], | ||
bar => [2, 'fasada'] | ||
; | ||
|
||
# argumentless form? | ||
gen '/', sub { | ||
return "lalala" | ||
} | ||
|
||
gen '/module', %modules, sub ($mod, $args) { | ||
return "$mod: " ~ $args[1] x $args[0]; | ||
} | ||
|
||
my $basedir = 'www'; # or maybe 'gen'? | ||
|
||
ok "$basedir/index.htm".IO.f; | ||
is slurp("$basedir/index.htm").chomp, 'lalala'; | ||
|
||
for %modules.kv -> $k, $v { | ||
ok "$basedir/module/$k/index.htm".IO.f; | ||
is slurp("$basedir/module/$k/index.htm").chomp, | ||
("$k: " ~ $v[1] x $v[0]); | ||
} | ||
|
||
rm_rf $basedir; # cleanup | ||
|
||
done; |