File: 01usages.t

package info (click to toggle)
libinline-perl 0.44-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 440 kB
  • ctags: 121
  • sloc: perl: 3,768; makefile: 38
file content (91 lines) | stat: -rw-r--r-- 1,538 bytes parent folder | download | duplicates (5)
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
81
82
83
84
85
86
87
88
89
90
91
use File::Spec;
use lib (File::Spec->catdir(File::Spec->curdir(),'blib','lib'), File::Spec->curdir());
use strict;
use Test;
use diagnostics;
use Inline Config => DIRECTORY => '_Inline_test';

BEGIN {
    plan(tests => 7,
	 todo => [],
	 onfail => sub {},
	);
}

use Inline Config => DIRECTORY => '_Inline_test';

# test 1
# Make sure that the syntax for reading external files works.
use Inline Foo => File::Spec->catfile(File::Spec->curdir(),'t','file');
ok(test1('test1'));

# test 2 & 3
# Make sure that data files work
use Inline Foo => 'DATA';
ok(test2('test2'));
use Inline 'Foo';
ok(not test3('test3'));

# test 4
# Make sure string form works
ok(test4('test4'));
use Inline Foo => <<'END_OF_FOO';
foo-sub test4 {
    foo-return $_[0] foo-eq 'test4';
}
END_OF_FOO

# test 5
# Make sure language name aliases work ('foo' instead of 'Foo')
ok(test5('test5'));
use Inline foo => <<'END_OF_FOO';
foo-sub test5 {
    foo-return $_[0] foo-eq 'test5';
}
END_OF_FOO

# test 6
# Make sure Inline->init works
eval <<'END';
use Inline Foo => 'DATA';
Inline->init;
ok(add(3, 7) == 10);

END

print "$@\nnot ok 1\n" if $@;

# test 7
# Make sure bind works
eval <<'END';
Inline->bind(Foo => <<'EOFOO');
foo-sub subtract {
    foo-return $_[0] foo-- $_[1];
}
EOFOO
ok(subtract(3, 7) == -4);

END

print "$@\nnot ok 2\n" if $@;

__END__

__Foo__
# Inline Foo file

foo-sub test2 {
    foo-return $_[0] foo-eq 'test2';
}

__Foo__

foo-sub test3 {
    foo-return $_[0] foo-eq 'yrlnry';
}

__Foo__

foo-sub add {
    foo-return $_[0] foo-+ $_[1];
}