File: t1_general.t

package info (click to toggle)
libquantum-entanglement-perl 0.32-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 120 kB
  • sloc: perl: 695; makefile: 2
file content (80 lines) | stat: -rwxr-xr-x 1,466 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Simple tests of Quantum::Entanglement

use strict;
use warnings;
use Test;
BEGIN {plan tests => 17, todo =>[]}

use Quantum::Entanglement qw(:DEFAULT :complex :QFT);

{ # entangle + boolean
  my $foo = entangle(1,1);
  my $bar = 0;
  $bar = 1 if $foo;
  ok(1,$bar);
}

{ # entangle + boolean + i
  my $foo = entangle(1*i,1);
  my $bar = 0;
  $bar = 1 if $foo;
  ok(1,$bar);
}

{ # stringification and operators
  my $foo = entangle(1,1,1*i,1);
  my $bar = entangle(1,2,1*i,2);
  { # *
    my $c = $foo * $bar;
    ok("$c",2);
  }
  {
    my $c = $foo + $bar;
    ok("$c",3);
  }  {
    my $c = $bar / $foo;
    ok("$c",2);
  }  {
    my $c = $foo % $bar;
    ok("$c",1);
  }  {
    my $c = $foo - $bar;
    ok("$c",-1);
  }  {
    my $c = $foo << $bar;
    ok("$c",4);
  }  {
    my $c = $foo >> $bar;
    ok("$c",0);
  } {
    my $c = $foo ** $bar;
    ok("$c",1);
  } {
    my $c = $foo x $bar;
    ok("$c",'11');
  }  {
    my $c = $foo . $bar;
    ok("$c",'12');
  }  {
    my $c = $foo & $bar;
    ok("$c",'0');
  }  {
    my $c = $foo | $bar;
    ok("$c",'3');
  }
}
{ # p_op
  my $foo = entangle(1,1,1*i,1);
  my $bar = entangle(1,2,1*i,2);
  {
    my $c = p_op($foo, '>', $bar, sub {'yes'}, sub {'no'});
    ok("$c", 'no');
  } {
    my $c = p_op($foo, '<', $bar, sub {'yes'}, sub {'no'});
    ok("$c", 'yes');
  } {
    my $c = p_op($foo, '<', $bar, sub {$QE::arg1 . $QE::arg2},
		                  sub {$QE::arg2 . $QE::arg1});
    ok("$c", '12');
  }
}