Skip to content

Commit

Permalink
Implement yaml_ok test function and add .read_string stub
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Jan 27, 2011
1 parent 74295e8 commit 002d898
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
36 changes: 36 additions & 0 deletions lib/YAML/Tiny.pm
@@ -1,6 +1,42 @@
#!nqp
class YAML::Tiny;

# The character class of all characters we need to escape
# NOTE: Inlined, since it's only used once
# my $RE_ESCAPE = '[\\x00-\\x08\\x0b-\\x0d\\x0e-\\x1f\"\n]';

# Printed form of the unprintable characters in the lowest range
# of ASCII characters, listed by ASCII ordinal position.
has @UNPRINTABLE := <
z x01 x02 x03 x04 x05 x06 a
x08 t n v f r x0e x0f
x10 x11 x12 x13 x14 x15 x16 x17
x18 x19 x1a e x1c x1d x1e x1f
>;

# Printable characters for escapes
has %UNESCAPES := hash(
z => "\x00", a => "\x07", t => "\x09",
n => "\x0a", v => "\x0b", f => "\x0c",
r => "\x0d", e => "\x1b",
#'\\' => '\\',
);

# Special magic boolean words
#has %QUOTE := map( -> $a { $a => 1; } <
# null Null NULL
# y Y yes Yes YES n N no No NO
# true True TRUE false False FALSE
# on On ON off Off OFF
#>);


method read_string($string) {
list();
}

INIT {
pir::load_bytecode("nqp-setting.pbc");
}

# vim: ft=perl6
4 changes: 3 additions & 1 deletion t/lib/Test.pm
Expand Up @@ -2,7 +2,9 @@
#module Test;

our sub yaml_ok($yaml, $expected, $description) {
ok(1, $description);
my $parser := YAML::Tiny.new;
my $result := $parser.read_string($yaml);
is_deeply($result, $expected, $description);
}

Q:PIR {
Expand Down

0 comments on commit 002d898

Please sign in to comment.