ported to test::output
[language-befunge.git] / t / 5-befunge / l-concur.t
blobf04c10be2207e0690ae2521ad7bc308511ec61f4
1 #!perl
3 # This file is part of Language::Befunge.
4 # Copyright (c) 2001-2008 Jerome Quelin, all rights reserved.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the same terms as Perl itself.
11 # -- concurrent funge
13 use strict;
14 use warnings;
16 use Test::More tests => 6;
17 use Test::Output;
19 use Language::Befunge;
20 my $bef = Language::Befunge->new;
23 # basic concurrency
24 $bef->store_code( <<'END_OF_CODE' );
25 #vtzz1.@
26  >2.@
27 END_OF_CODE
28 stdout_is { $bef->run_code } '2 1 ', 'basic concurrency';
31 # q kills all ips running
32 $bef->store_code( <<'END_OF_CODE' );
33 #vtq
34  >123...@
35 END_OF_CODE
36 stdout_is { $bef->run_code } '', 'q kills all ips running';
39 # cloning the stack
40 $bef->store_code( <<'END_OF_CODE' );
41 123 #vtzz...@
42      >...@
43 END_OF_CODE
44 stdout_is { $bef->run_code } '3 3 2 2 1 1 ', 'threading clones the stack';
47 # spaces are one no-op
48 $bef->store_code( <<'END_OF_CODE' );
49 #vtzzz2.@
50  >         1.@
51 END_OF_CODE
52 stdout_is { $bef->run_code } '1 2 ', 'spaces are one no-op';
55 # comments are one no-op
56 $bef->store_code( <<'END_OF_CODE' );
57 #vtzzz2.@
58  >;this is a comment;1.@
59 END_OF_CODE
60 stdout_is { $bef->run_code } '1 2 ', 'comments are one no-op';
63 # repeat instructions are one op
64 $bef->store_code( <<'END_OF_CODE' );
65 #vtzzzzz2.@
66  >1112k.@
67 END_OF_CODE
68 stdout_is { $bef->run_code } '1 1 2 1 ', 'repeat instr is one op';