Permalink
Browse files

collapse a test into the actual implementation

After #141, the test actually became meaningless without us quite
realizing it.

What does the test check for? It checks that there's a consistency
between the Val.pm and Q.pm files on the one hand and the
Runtime/Builtins.pm file on the other. But the #141 upgrade
actually provides a way for the code itself to ask this question,
and automatically keep things consistent. So it shouldn't be a
test anymore, it should be the code.

And now, it is.
  • Loading branch information...
masak committed Jun 22, 2016
1 parent fa5aa9f commit d622d372d4dfd10a705d978f940e16673eeaedd2
Showing with 12 additions and 124 deletions.
  1. +12 −90 lib/_007/Runtime/Builtins.pm
  2. +0 −34 t/integration/val-q-classes.t
@@ -376,97 +376,19 @@ class _007::Runtime::Builtins {
),
;
my @val-types =
Val::Array,
Val::Block,
Val::Int,
Val::None,
Val::Macro,
Val::Object,
Val::Str,
Val::Sub,
Val::Type,
Val::Exception,
;
for @val-types -> $type {
push @builtins, ($type.^name.subst("Val::", "") => Val::Type.of($type));
}
my @q-types =
Q::ArgumentList,
Q::Block,
Q::CompUnit,
Q::Declaration,
Q::Expr,
Q::Expr::StatementListAdapter,
Q::Identifier,
Q::Infix,
Q::Infix::Addition,
Q::Infix::Subtraction,
Q::Infix::Modulo,
Q::Infix::Divisibility,
Q::Infix::DefinedOr,
Q::Infix::Multiplication,
Q::Infix::Concat,
Q::Infix::Assignment,
Q::Infix::Eq,
Q::Infix::Ne,
Q::Infix::Gt,
Q::Infix::Ge,
Q::Infix::Lt,
Q::Infix::Le,
Q::Infix::And,
Q::Infix::Or,
Q::Infix::TypeEq,
Q::Infix::Replicate,
Q::Infix::ArrayReplicate,
Q::Infix::Cons,
Q::Literal,
Q::Literal::Int,
Q::Literal::None,
Q::Literal::Str,
Q::Parameter,
Q::ParameterList,
Q::Postfix,
Q::Postfix::Index,
Q::Postfix::Call,
Q::Postfix::Property,
Q::Prefix,
Q::Prefix::Minus,
Q::Prefix::Not,
Q::Prefix::Upto,
Q::Property,
Q::PropertyList,
Q::Statement,
Q::Statement::BEGIN,
Q::Statement::Block,
Q::Statement::Constant,
Q::Statement::Expr,
Q::Statement::For,
Q::Statement::Macro,
Q::Statement::If,
Q::Statement::My,
Q::Statement::Return,
Q::Statement::Sub,
Q::Statement::Throw,
Q::Statement::While,
Q::StatementList,
Q::Term,
Q::Term::Array,
Q::Term::Object,
Q::Term::Quasi,
Q::Term::Sub,
Q::Trait,
Q::TraitList,
Q::Unquote,
Q::Unquote::Infix,
Q::Unquote::Prefix,
;
for @q-types -> $type {
push @builtins, ($type.^name => Val::Type.of($type));
sub tree-walk(%package) {
for %package.keys.map({ %package ~ "::$_" }) -> $name {
# make a little exception for Val::Sub::Builtin, which is just an
# implementation detail and doesn't have a corresponding builtin
# (because it tries to pass itself off as a Val::Sub)
next if $name eq "Val::Sub::Builtin";
my $type = ::($name);
push @builtins, ($type.^name.subst("Val::", "") => Val::Type.of($type));
tree-walk($type.WHO);
}
}
tree-walk(Val::);
tree-walk(Q::);
sub _007ize(&fn) {
return sub (|c) { wrap &fn(|c) };
@@ -1,34 +0,0 @@
use v6;
use Test;
use _007;
sub tree-walk(%package, @accum) {
for %package.keys.map({ %package ~ "::$_" }) -> $name {
# make a little exception for Val::Sub::Builtin, which is just an
# implementation detail and doesn't have a corresponding builtin
# (because it tries to pass itself off as a Val::Sub)
next if $name eq "Val::Sub::Builtin";
push @accum, $name;
tree-walk(::($name).WHO , @accum);
}
}
my @p6types;
tree-walk(Q::, @p6types);
tree-walk(Val::, @p6types);
my @builtins = "lib/_007/Runtime/Builtins.pm".IO.lines.map({
~$0 if /^ \h+ ([Val|Q] "::" <-[,]>+) "," \h* $/
});
{
my $missing-p6types = (@builtins (-) @p6types).keys.map({ "- $_" }).join("\n");
is $missing-p6types, "", "all built-in types are also p6 types";
}
{
my $missing-builtins = (@p6types (-) @builtins).keys.map({ "- $_" }).join("\n");
is $missing-builtins, "", "all p6 types are also built-in types";
}
done-testing;

0 comments on commit d622d37

Please sign in to comment.