Skip to content

Commit

Permalink
renamed transform to call
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Feb 24, 2013
1 parent 8b7b9c7 commit a1a3f1e
Show file tree
Hide file tree
Showing 20 changed files with 228 additions and 229 deletions.
8 changes: 4 additions & 4 deletions README
Expand Up @@ -45,8 +45,8 @@ SYNOPSIS
-testml => 'testml/encode.tml',
-bridge => 't::Bridge';

The apply_* transform functions are defined in the bridge class that is
specified outside this test (t/Bridge.pm).
The apply_* functions are defined in the bridge class that is specified
outside this test (t/Bridge.pm).

DESCRIPTION
TestML is a generic, programming language agnostic, meta language for
Expand All @@ -58,8 +58,8 @@ DESCRIPTION
In a nutshell you write a bunch of data tests that have inputs and
expected results. Using a simple syntax, you specify what functions the
data must pass through to produce the expected results. You use a bridge
class to write the data transform functions that pass the data through
your application.
class to write the data functions that pass the data through your
application.

In Perl 5, TestML is the evolution of the Test::Base module. It has a
superset of Test:Base's goals. The data markup syntax is currently
Expand Down
36 changes: 17 additions & 19 deletions lib/TestML.pm
Expand Up @@ -110,11 +110,11 @@ has compiler => ( default => sub {'TestML::Lite::Compiler'} );
--- text: soopersekrit
--- md5: 64002c26dcc62c1d6d0f1cb908de1435
This TestML document defines 2 assertions, and defines 2 data blocks.
The first block has 3 data points, but the second one has only 2.
Therefore the rot13 assertion applies only to the first block, while the
the md5 assertion applies to both. This results in a total of 3 tests,
which is specified in the meta Plan statement in the document.
This TestML document defines 2 assertions, and defines 2 data blocks. The
first block has 3 data points, but the second one has only 2. Therefore the
rot13 assertion applies only to the first block, while the the md5 assertion
applies to both. This results in a total of 3 tests, which is specified in the
meta Plan statement in the document.
To run this test you would have a normal test file that looks like this:
Expand All @@ -131,23 +131,21 @@ or more simply:
-testml => 'testml/encode.tml',
-bridge => 't::Bridge';
The apply_* transform functions are defined in the bridge class that is
specified outside this test (t/Bridge.pm).
The apply_* functions are defined in the bridge class that is specified outside
this test (t/Bridge.pm).
=head1 DESCRIPTION
TestML is a generic, programming language agnostic, meta language for
writing unit tests. The idea is that you can use the same test files in
multiple implementations of a given programming idea. Then you can be
more certain that your application written in, say, Python matches your
Perl implementation.
TestML is a generic, programming language agnostic, meta language for writing
unit tests. The idea is that you can use the same test files in multiple
implementations of a given programming idea. Then you can be more certain that
your application written in, say, Python matches your Perl implementation.
In a nutshell you write a bunch of data tests that have inputs and
expected results. Using a simple syntax, you specify what functions the
data must pass through to produce the expected results. You use a bridge
class to write the data transform functions that pass the data through
your application.
In a nutshell you write a bunch of data tests that have inputs and expected
results. Using a simple syntax, you specify what functions the data must pass
through to produce the expected results. You use a bridge class to write the
data functions that pass the data through your application.
In Perl 5, TestML is the evolution of the L<Test::Base> module. It has a
superset of Test:Base's goals. The data markup syntax is currently
exactly the same as Test::Base.
superset of Test:Base's goals. The data markup syntax is currently exactly the
same as Test::Base.
15 changes: 8 additions & 7 deletions lib/TestML/AST.pm
Expand Up @@ -23,7 +23,7 @@ sub got_assignment_statement {
return TestML::Statement->new(
expression => TestML::Expression->new(
units => [
TestML::Transform->new(
TestML::Call->new(
name => 'Set',
args => [
$match->[0],
Expand Down Expand Up @@ -86,7 +86,7 @@ sub got_point_object {
my ($self, $point) = @_;
$point =~ s/^\*// or die;
push @{$self->points}, $point;
return TestML::Transform->new(
return TestML::Call->new(
name => 'Point',
args => [$point],
);
Expand Down Expand Up @@ -148,22 +148,23 @@ sub got_function_object {
return $function;
}

# XXX Change 'transform' to 'call' (requires change in grammar).
sub got_transform_name {
my ($self, $match) = @_;
return TestML::Transform->new(name => $match);
return TestML::Call->new(name => $match);
}

sub got_transform_object {
my ($self, $object) = @_;
my $transform = $object->[0];
my $call = $object->[0];
if ($object->[1][-1] and $object->[1][-1] eq 'explicit') {
$transform->explicit_call(1);
$call->explicit_call(1);
splice @{$object->[1]}, -1, 1;
}
my $args = [];
$args = $object->[1][0] if $object->[1][0];
$transform->args($args) if @$args;
return $transform;
$call->args($args) if @$args;
return $call;
}

sub got_transform_argument_list {
Expand Down
4 changes: 2 additions & 2 deletions lib/TestML/Lite/Compiler.pm
Expand Up @@ -74,12 +74,12 @@ sub compile_assertion {
: $self->make_unit($_, $points);
} @args
];
my $transform = TestML::Transform->new(
my $call = TestML::Call->new(
name => $token->[0],
args => $args,
explicit_call => 1,
);
push @{$side->units}, $transform;
push @{$side->units}, $call;
} ||
$token->isa('TestML::Object') && do {
push @{$side->units}, $token;
Expand Down
20 changes: 10 additions & 10 deletions lib/TestML/Runtime.pm
Expand Up @@ -10,11 +10,11 @@ our $self;

has base => default => sub {$0 =~ m!(.*)/! ? $1 : "."}; # Base directory
has testml => (); # TestML document filename, handle or text
has bridge => (); # Bridge transform module
has bridge => (); # Bridge call module
has compiler => (); # TestML Compiler module

# XXX Add TestML.pm support for -library keyword.
has library => default => sub {[]}; # Transform library modules
has library => default => sub {[]}; # Call library modules

has function => (); # Current function executing
has planned => default => sub {0}; # plan() has been called
Expand All @@ -35,11 +35,11 @@ sub run {
$self->{function} = $self->compile_testml;
$self->load_variables;

$self->load_transform_module('TestML::Library::Standard');
$self->load_transform_module('TestML::Library::Debug');
$self->load_call_module('TestML::Library::Standard');
$self->load_call_module('TestML::Library::Debug');

if ($self->bridge) {
$self->load_transform_module($self->bridge);
$self->load_call_module($self->bridge);
}

my $context = TestML::None->new;
Expand Down Expand Up @@ -146,7 +146,7 @@ sub run_expression {
my $unit = $units->[$i];
if ($expression->error) {
next unless
$unit->isa('TestML::Transform') and
$unit->isa('TestML::Call') and
$unit->name eq 'Catch';
}
if ($unit->isa('TestML::Point')) {
Expand All @@ -161,9 +161,9 @@ sub run_expression {
$context = $unit;
next;
}
die "Unexpected unit: $unit" unless $unit->isa('TestML::Transform');
die "Unexpected unit: $unit" unless $unit->isa('TestML::Call');
my $callable = $self->function->getvar($unit->name)
or die "Can't find transform '${\$unit->name}'";
or die "Can't find callable '${\$unit->name}'";
my $args = [
map {
$_->isa('TestML::Point')
Expand Down Expand Up @@ -287,7 +287,7 @@ sub load_variables {
$global->setvar(None => $TestML::Constant::None);
}

sub load_transform_module {
sub load_call_module {
my $self = shift;
my $module_name = shift;
if ($module_name ne 'main') {
Expand Down Expand Up @@ -426,7 +426,7 @@ has name => ();
has expression => default => sub {TestML::Expression->new};

#-----------------------------------------------------------------------------
package TestML::Transform;
package TestML::Call;
use TestML::Mo;

has name => ();
Expand Down
4 changes: 2 additions & 2 deletions notes/Glossary
Expand Up @@ -4,6 +4,8 @@

* Block Label

* Call Function

* Data Set

* Data Block
Expand All @@ -30,8 +32,6 @@

* Test Function

* Transform Function

* Variable


4 changes: 2 additions & 2 deletions notes/ToDo
Expand Up @@ -16,7 +16,7 @@
+ Rename TestML::Parser::Grammar to TestML::Grammar
+ Delete t/runner.t
+ Put TestML::AST into TestML::Runtime
+ Rename TestML::Transform::* -> TestML::Library
+ Rename TestML::Call::* -> TestML::Library
+ True/False/None can be singleton objects
+ Make TestML::Object::type a method that returns type based on class.
+ Add getvar / setvar in Function for variable access.
Expand Down Expand Up @@ -45,7 +45,7 @@
- XXX, et al are not reporting the correct line they came from.

== Standard
- Add a standard transform for data parse
- Add a standard call for data parse

- Allow quotes for line points
- Support Native objects
Expand Down
28 changes: 14 additions & 14 deletions t/ast/arguments.tml
Expand Up @@ -20,7 +20,7 @@ statements:
- !!perl/hash:TestML::Statement
expression: !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- Plan
- !!perl/hash:TestML::Expression
Expand All @@ -32,22 +32,22 @@ statements:
assertion: !!perl/hash:TestML::Assertion
expression: !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- greeting
name: Point
name: EQ
expression: !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- what
name: Point
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- who
name: Point
Expand All @@ -61,26 +61,26 @@ statements:
assertion: !!perl/hash:TestML::Assertion
expression: !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- greeting
name: Point
name: EQ
expression: !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- what
name: Point
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Str
value: and
- !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- else
name: Point
Expand All @@ -94,30 +94,30 @@ statements:
assertion: !!perl/hash:TestML::Assertion
expression: !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- upper_greeting
name: Point
name: EQ
expression: !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- what
name: Point
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Str
value: and
- !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- else
name: Point
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
name: uppercase
explicit_call: 1
name: combine
Expand Down
8 changes: 4 additions & 4 deletions t/ast/assertions.tml
Expand Up @@ -6,7 +6,7 @@ statements:
- !!perl/hash:TestML::Statement
expression: !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- Plan
- !!perl/hash:TestML::Expression
Expand All @@ -17,7 +17,7 @@ statements:
- !!perl/hash:TestML::Statement
expression: !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- Label
- !!perl/hash:TestML::Expression
Expand Down Expand Up @@ -50,7 +50,7 @@ statements:
- !!perl/hash:TestML::Statement
expression: !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- Label
- !!perl/hash:TestML::Expression
Expand Down Expand Up @@ -83,7 +83,7 @@ statements:
- !!perl/hash:TestML::Statement
expression: !!perl/hash:TestML::Expression
units:
- !!perl/hash:TestML::Transform
- !!perl/hash:TestML::Call
args:
- Label
- !!perl/hash:TestML::Expression
Expand Down

0 comments on commit a1a3f1e

Please sign in to comment.