openwferu 0.9.16 → 0.9.17
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/about_state.rb +81 -0
- data/examples/engine_template.rb +7 -0
- data/lib/openwfe/contextual.rb +2 -2
- data/lib/openwfe/def.rb +2 -3
- data/lib/openwfe/{util/schedulers.rb → engine.rb} +3 -39
- data/lib/openwfe/engine/engine.rb +202 -251
- data/lib/openwfe/engine/process_status.rb +359 -0
- data/lib/openwfe/expool/errorjournal.rb +6 -6
- data/lib/openwfe/expool/expressionpool.rb +161 -239
- data/lib/openwfe/expool/expstorage.rb +185 -55
- data/lib/openwfe/expool/journal.rb +1 -2
- data/lib/openwfe/expool/parser.rb +233 -0
- data/lib/openwfe/expool/threadedexpstorage.rb +6 -18
- data/lib/openwfe/expool/wfidgen.rb +25 -7
- data/lib/openwfe/expool/yamlexpstorage.rb +60 -37
- data/lib/openwfe/expressions/condition.rb +49 -12
- data/lib/openwfe/expressions/environment.rb +45 -15
- data/lib/openwfe/expressions/expressionmap.rb +39 -19
- data/lib/openwfe/expressions/fe_concurrence.rb +24 -13
- data/lib/openwfe/expressions/fe_cron.rb +19 -18
- data/lib/openwfe/expressions/fe_cursor.rb +69 -28
- data/lib/openwfe/expressions/fe_define.rb +4 -1
- data/lib/openwfe/expressions/fe_do.rb +1 -3
- data/lib/openwfe/expressions/fe_equals.rb +131 -20
- data/lib/openwfe/expressions/fe_fqv.rb +27 -3
- data/lib/openwfe/expressions/fe_iterator.rb +14 -7
- data/lib/openwfe/expressions/fe_listen.rb +7 -2
- data/lib/openwfe/expressions/fe_misc.rb +187 -20
- data/lib/openwfe/expressions/fe_participant.rb +8 -7
- data/lib/openwfe/expressions/fe_reserve.rb +105 -33
- data/lib/openwfe/expressions/fe_save.rb +55 -5
- data/lib/openwfe/expressions/{fe_value.rb → fe_set.rb} +6 -82
- data/lib/openwfe/expressions/fe_sleep.rb +25 -15
- data/lib/openwfe/expressions/fe_subprocess.rb +2 -2
- data/lib/openwfe/expressions/fe_wait.rb +3 -2
- data/lib/openwfe/expressions/fe_when.rb +7 -15
- data/lib/openwfe/expressions/flowexpression.rb +90 -49
- data/lib/openwfe/expressions/merge.rb +7 -1
- data/lib/openwfe/expressions/raw.rb +261 -63
- data/lib/openwfe/expressions/{raw_prog.rb → rprocdef.rb} +94 -179
- data/lib/openwfe/expressions/time.rb +36 -12
- data/lib/openwfe/expressions/timeout.rb +9 -7
- data/lib/openwfe/expressions/value.rb +126 -0
- data/lib/openwfe/flowexpressionid.rb +52 -22
- data/lib/openwfe/listeners/listeners.rb +3 -3
- data/lib/openwfe/listeners/socketlisteners.rb +8 -5
- data/lib/openwfe/logging.rb +6 -3
- data/lib/openwfe/omixins.rb +8 -6
- data/lib/openwfe/orest/xmlcodec.rb +16 -12
- data/lib/openwfe/participants.rb +38 -0
- data/lib/openwfe/participants/participant.rb +1 -1
- data/lib/openwfe/participants/participantmap.rb +24 -10
- data/lib/openwfe/participants/participants.rb +4 -3
- data/lib/openwfe/participants/soapparticipants.rb +1 -1
- data/lib/openwfe/participants/socketparticipants.rb +1 -1
- data/lib/openwfe/rudefinitions.rb +7 -5
- data/lib/openwfe/storage/yamlcustom.rb +10 -10
- data/lib/openwfe/storage/yamlfilestorage.rb +12 -12
- data/lib/openwfe/tools/flowtracer.rb +6 -5
- data/lib/openwfe/util/dollar.rb +42 -85
- data/lib/openwfe/util/ometa.rb +1 -3
- data/lib/openwfe/util/workqueue.rb +1 -1
- data/lib/openwfe/utils.rb +33 -11
- data/lib/openwfe/version.rb +2 -2
- data/lib/openwfe/workitem.rb +76 -14
- data/lib/openwfe/worklist/storelocks.rb +9 -4
- data/lib/openwfe/worklist/storeparticipant.rb +1 -1
- data/test/back_0916_test.rb +101 -0
- data/test/bm/ft_26_load.rb +1 -1
- data/test/bm/ft_26b_load.rb +1 -1
- data/test/bm/ft_26c_load.rb +3 -2
- data/test/bm/ft_26d_load.rb +97 -0
- data/test/bm/ft_recu.rb +71 -0
- data/test/concurrence_test.rb +1 -1
- data/test/condition_test.rb +152 -0
- data/test/description_test.rb +12 -7
- data/test/eno_test.rb +1 -1
- data/test/expool_20031219_0916.tgz +0 -0
- data/test/fe_lookup_att_test.rb +1 -1
- data/test/fei_test.rb +16 -0
- data/test/file_persistence_test.rb +8 -12
- data/test/filep_cancel_test.rb +116 -0
- data/test/flowtestbase.rb +47 -25
- data/test/ft_0.rb +1 -1
- data/test/ft_10_loop.rb +29 -14
- data/test/{ft_10b_loop2.rb → ft_10b_loop.rb} +2 -11
- data/test/ft_11_ppd.rb +6 -17
- data/test/ft_11b_ppd.rb +1 -4
- data/test/ft_12_blockparticipant.rb +1 -1
- data/test/ft_13_eno.rb +1 -1
- data/test/ft_15_iterator.rb +1 -1
- data/test/ft_15b_iterator.rb +1 -1
- data/test/ft_17_condition.rb +6 -6
- data/test/ft_18_pname.rb +1 -1
- data/test/ft_20_cron.rb +1 -1
- data/test/ft_21_cron.rb +6 -4
- data/test/ft_22_history.rb +1 -1
- data/test/ft_23_when.rb +1 -1
- data/test/ft_23b_when.rb +18 -6
- data/test/ft_23c_wait.rb +8 -6
- data/test/ft_25_cancel.rb +7 -5
- data/test/ft_27_getflowpos.rb +22 -17
- data/test/ft_28_fileparticipant.rb +1 -2
- data/test/ft_2_concurrence.rb +1 -1
- data/test/ft_2b_concurrence.rb +25 -20
- data/test/ft_30_socketlistener.rb +0 -3
- data/test/ft_34_cancelwfid.rb +9 -9
- data/test/ft_35_localdefs.rb +0 -1
- data/test/ft_36_subprocids.rb +6 -6
- data/test/ft_38_tag.rb +3 -2
- data/test/ft_38b_tag.rb +229 -0
- data/test/ft_39_reserve.rb +3 -18
- data/test/ft_39b_reserve.rb +34 -5
- data/test/ft_3b_lookup_vf.rb +83 -0
- data/test/ft_40_defined.rb +2 -11
- data/test/ft_42_environments.rb +4 -6
- data/test/ft_44b_restore.rb +88 -22
- data/test/ft_45_citerator.rb +57 -11
- data/test/ft_49_condition.rb +4 -2
- data/test/ft_4_misc.rb +24 -3
- data/test/ft_50_xml_attribute.rb +17 -20
- data/test/ft_54_listen.rb +1 -1
- data/test/ft_54b_listen.rb +2 -2
- data/test/ft_56_timeout.rb +8 -1
- data/test/ft_57_a.rb +10 -10
- data/test/ft_59_ps.rb +49 -16
- data/test/ft_60_ecancel.rb +52 -10
- data/test/ft_63_pause.rb +8 -8
- data/test/ft_65_stringlaunch.rb +4 -6
- data/test/ft_67_schedlaunch.rb +4 -4
- data/test/ft_69_cancelmissing.rb +4 -2
- data/test/ft_70_lookupvar.rb +2 -2
- data/test/ft_72_lookup_processes.rb +2 -2
- data/test/ft_73_cancel_sub.rb +8 -8
- data/test/ft_77_segments.rb +38 -0
- data/test/ft_78_eval.rb +154 -0
- data/test/ft_79_tticket.rb +185 -0
- data/test/ft_80_spname.rb +95 -0
- data/test/ft_81_exp.rb +64 -0
- data/test/ft_82_trecu.rb +48 -0
- data/test/ft_83_badpause.rb +62 -0
- data/test/ft_84_updateexp.rb +125 -0
- data/test/ft_9b_cursor.rb +105 -0
- data/test/ft_tests.rb +14 -1
- data/test/hash_test.rb +7 -7
- data/test/hparticipant_test.rb +4 -4
- data/test/lookup_vf_test.rb +94 -0
- data/test/misc_test.rb +5 -3
- data/test/orest_test.rb +4 -3
- data/test/param_test.rb +12 -16
- data/test/participant_test.rb +36 -0
- data/test/pending.rb +10 -10
- data/test/rake_ltest.rb +1 -10
- data/test/rake_qtest.rb +7 -6
- data/test/raw_prog_test.rb +89 -121
- data/test/restart_cron_test.rb +84 -36
- data/test/restart_paused_test.rb +100 -0
- data/test/restart_sleep_test.rb +1 -1
- data/test/restart_tests.rb +1 -0
- data/test/restart_when_test.rb +33 -22
- data/test/ruby_procdef_test.rb +19 -18
- data/test/sec_test.rb +74 -35
- data/test/storage_test.rb +44 -0
- data/test/test.rb +3 -0
- data/test/timeout_test.rb +7 -18
- data/test/wfid_test.rb +2 -1
- data/test/wi_test.rb +29 -18
- metadata +121 -57
- data/lib/openwfe/expressions/raw_xml.rb +0 -176
- data/lib/openwfe/expressions/simplerep.rb +0 -266
- data/lib/openwfe/util/kotoba.rb +0 -236
- data/lib/openwfe/util/lru.rb +0 -171
- data/lib/openwfe/util/otime.rb +0 -246
- data/lib/openwfe/util/safe.rb +0 -160
- data/lib/openwfe/util/scheduler.rb +0 -1158
- data/test/cron_test.rb +0 -113
- data/test/cronline_test.rb +0 -60
- data/test/dollar_test.rb +0 -90
- data/test/kotoba_test.rb +0 -72
- data/test/lru_test.rb +0 -79
- data/test/safely_test.rb +0 -84
- data/test/scheduler_1_test.rb +0 -88
- data/test/scheduler_test.rb +0 -363
- data/test/time_test.rb +0 -84
data/test/cron_test.rb
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Testing OpenWFE
|
4
|
-
#
|
5
|
-
# John Mettraux at openwfe.org
|
6
|
-
#
|
7
|
-
# Sun Oct 29 16:18:25 JST 2006
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'test/unit'
|
11
|
-
|
12
|
-
require 'openwfe/util/otime'
|
13
|
-
require 'openwfe/util/scheduler'
|
14
|
-
|
15
|
-
|
16
|
-
#
|
17
|
-
# testing otime and the scheduler (its cron aspect)
|
18
|
-
#
|
19
|
-
class CronTest < Test::Unit::TestCase
|
20
|
-
|
21
|
-
#def setup
|
22
|
-
#end
|
23
|
-
|
24
|
-
#def teardown
|
25
|
-
#end
|
26
|
-
|
27
|
-
def test_0
|
28
|
-
|
29
|
-
$var = 0
|
30
|
-
|
31
|
-
scheduler = OpenWFE::Scheduler.new
|
32
|
-
scheduler.start
|
33
|
-
|
34
|
-
sid = scheduler.schedule(
|
35
|
-
'* * * * *',
|
36
|
-
:schedulable => CounterSchedulable.new)
|
37
|
-
|
38
|
-
assert sid, "scheduler did not return a job id"
|
39
|
-
|
40
|
-
sleep 120
|
41
|
-
scheduler.stop
|
42
|
-
|
43
|
-
#puts ">#{$var}<"
|
44
|
-
|
45
|
-
assert_equal $var, 2, "$var should be at 2, it's at #{$var}"
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_1
|
49
|
-
|
50
|
-
scheduler = OpenWFE::Scheduler.new
|
51
|
-
scheduler.start
|
52
|
-
|
53
|
-
sec = nil
|
54
|
-
has_gone_wrong = false
|
55
|
-
counter = 0
|
56
|
-
|
57
|
-
scheduler.schedule "* * * * * *" do
|
58
|
-
t = Time.new
|
59
|
-
if (t.sec == sec)
|
60
|
-
has_gone_wrong = true
|
61
|
-
#print "x"
|
62
|
-
else
|
63
|
-
#print "."
|
64
|
-
end
|
65
|
-
#STDOUT.flush
|
66
|
-
sec = t.sec
|
67
|
-
counter = counter + 1
|
68
|
-
end
|
69
|
-
|
70
|
-
sleep 10
|
71
|
-
scheduler.stop
|
72
|
-
|
73
|
-
assert_equal 10, counter
|
74
|
-
assert (not has_gone_wrong)
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_2
|
78
|
-
|
79
|
-
scheduler = OpenWFE::Scheduler.new
|
80
|
-
scheduler.start
|
81
|
-
|
82
|
-
seen = false
|
83
|
-
has_gone_wrong = false
|
84
|
-
|
85
|
-
scheduler.schedule "7 * * * * *" do
|
86
|
-
if seen
|
87
|
-
has_gone_wrong = true
|
88
|
-
#print "x"
|
89
|
-
else
|
90
|
-
seen = true
|
91
|
-
#print "."
|
92
|
-
end
|
93
|
-
#STDOUT.flush
|
94
|
-
end
|
95
|
-
|
96
|
-
sleep 61
|
97
|
-
scheduler.stop
|
98
|
-
|
99
|
-
assert seen
|
100
|
-
assert (not has_gone_wrong)
|
101
|
-
end
|
102
|
-
|
103
|
-
protected
|
104
|
-
|
105
|
-
class CounterSchedulable
|
106
|
-
include OpenWFE::Schedulable
|
107
|
-
|
108
|
-
def trigger (params)
|
109
|
-
$var = $var + 1
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
data/test/cronline_test.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Testing OpenWFE
|
4
|
-
#
|
5
|
-
# John Mettraux at openwfe.org
|
6
|
-
#
|
7
|
-
# Sun Oct 29 16:18:25 JST 2006
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'pp'
|
11
|
-
require 'test/unit'
|
12
|
-
|
13
|
-
require 'openwfe/util/scheduler'
|
14
|
-
|
15
|
-
|
16
|
-
#
|
17
|
-
# testing the Scheduler's CronLine system
|
18
|
-
#
|
19
|
-
class CronLineTest < Test::Unit::TestCase
|
20
|
-
|
21
|
-
#def setup
|
22
|
-
#end
|
23
|
-
|
24
|
-
#def teardown
|
25
|
-
#end
|
26
|
-
|
27
|
-
def do_cltest (line, array)
|
28
|
-
cl = OpenWFE::CronLine.new(line)
|
29
|
-
|
30
|
-
unless cl.to_array == array
|
31
|
-
puts
|
32
|
-
pp cl.to_array
|
33
|
-
puts " should be"
|
34
|
-
pp array
|
35
|
-
end
|
36
|
-
|
37
|
-
assert \
|
38
|
-
cl.to_array == array
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_0
|
42
|
-
|
43
|
-
do_cltest "* * * * *", [ [0], nil, nil, nil, nil, nil ]
|
44
|
-
do_cltest "10-12 * * * *", [ [0], [10, 11, 12], nil, nil, nil, nil ]
|
45
|
-
do_cltest "* * * * sun,mon", [ [0], nil, nil, nil, nil, [7, 1] ]
|
46
|
-
do_cltest "* * * * mon-wed", [ [0], nil, nil, nil, nil, [1, 2, 3] ]
|
47
|
-
|
48
|
-
#do_cltest "* * * * sun,mon-tue", [ [0], nil, nil, nil, nil, [7, 1, 2] ]
|
49
|
-
#do_cltest "* * * * 7-1", [ [0], nil, nil, nil, nil, [7, 1, 2] ]
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_1
|
53
|
-
|
54
|
-
do_cltest "* * * * * *", [ nil, nil, nil, nil, nil, nil ]
|
55
|
-
do_cltest "1 * * * * *", [ [1], nil, nil, nil, nil, nil ]
|
56
|
-
do_cltest "7 10-12 * * * *", [ [7], [10, 11, 12], nil, nil, nil, nil ]
|
57
|
-
do_cltest "1-5 * * * * *", [ [1,2,3,4,5], nil, nil, nil, nil, nil ]
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
data/test/dollar_test.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Testing OpenWFE
|
4
|
-
#
|
5
|
-
# John Mettraux at openwfe.org
|
6
|
-
#
|
7
|
-
# Mon Oct 9 22:19:44 JST 2006
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'test/unit'
|
11
|
-
require 'openwfe/util/dollar'
|
12
|
-
|
13
|
-
#
|
14
|
-
# testing the 'dollar notation'
|
15
|
-
#
|
16
|
-
|
17
|
-
class DollarTest < Test::Unit::TestCase
|
18
|
-
|
19
|
-
#def setup
|
20
|
-
#end
|
21
|
-
|
22
|
-
#def teardown
|
23
|
-
#end
|
24
|
-
|
25
|
-
def test_0
|
26
|
-
|
27
|
-
dict = {}
|
28
|
-
|
29
|
-
dict['renard'] = 'goupil'
|
30
|
-
dict['cane'] = 'oie'
|
31
|
-
dict['oie blanche'] = 'poule'
|
32
|
-
|
33
|
-
dotest("le petit renard", dict, "le petit renard")
|
34
|
-
dotest("le petit {renard}", dict, "le petit {renard}")
|
35
|
-
dotest("le petit ${renard}", dict, "le petit goupil")
|
36
|
-
dotest("le petit ${renard} noir", dict, "le petit goupil noir")
|
37
|
-
|
38
|
-
dotest("la grande ${${cane} blanche}", dict, "la grande poule")
|
39
|
-
|
40
|
-
dotest("le ${renard} et la ${cane}", dict, "le goupil et la oie")
|
41
|
-
#
|
42
|
-
# excuse my french...
|
43
|
-
|
44
|
-
dotest("le \\${renard} encore", dict, "le \\${renard} encore")
|
45
|
-
|
46
|
-
dotest("", dict, "")
|
47
|
-
|
48
|
-
dotest("""
|
49
|
-
""", dict, """
|
50
|
-
""")
|
51
|
-
dotest("""
|
52
|
-
""", dict, """
|
53
|
-
""")
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_1
|
57
|
-
|
58
|
-
dict = {}
|
59
|
-
dict['x'] = 'y'
|
60
|
-
|
61
|
-
dotest("${x}", dict, "y")
|
62
|
-
dotest("\\${x}", dict, "\\${x}")
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_2
|
66
|
-
|
67
|
-
dict = {}
|
68
|
-
dict['A'] = 'a'
|
69
|
-
dict['B'] = 'b'
|
70
|
-
dict['ab'] = 'ok'
|
71
|
-
|
72
|
-
dotest("${${A}${B}}", dict, "ok")
|
73
|
-
end
|
74
|
-
|
75
|
-
#def test_3
|
76
|
-
# assert_equal OpenWFE.unescape("toto and ${toto}"), "toto and ${toto}"
|
77
|
-
# assert_equal OpenWFE.unescape("toto & \${toto}"), "toto & ${toto}"
|
78
|
-
# assert_equal "toto & \\${toto}", "toto & ${toto}"
|
79
|
-
# #assert_equal OpenWFE.unescape('toto & \${toto}'), "toto & ${toto}"
|
80
|
-
#end
|
81
|
-
|
82
|
-
def dotest (text, dict, target)
|
83
|
-
result = OpenWFE::dsub(text, dict)
|
84
|
-
#puts "..>#{text}<"
|
85
|
-
#puts "...->"
|
86
|
-
#puts "..>#{result}<"
|
87
|
-
#puts
|
88
|
-
assert_equal result, target
|
89
|
-
end
|
90
|
-
end
|
data/test/kotoba_test.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Testing OpenWFE (Kotoba)
|
4
|
-
#
|
5
|
-
# John Mettraux at openwfe.org
|
6
|
-
#
|
7
|
-
# Sun Mar 18 13:29:37 JST 2007
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'test/unit'
|
11
|
-
require 'openwfe/util/kotoba'
|
12
|
-
|
13
|
-
#
|
14
|
-
# testing misc things
|
15
|
-
#
|
16
|
-
|
17
|
-
class KotobaTest < Test::Unit::TestCase
|
18
|
-
|
19
|
-
#def setup
|
20
|
-
#end
|
21
|
-
|
22
|
-
#def teardown
|
23
|
-
#end
|
24
|
-
|
25
|
-
def test_kotoba
|
26
|
-
t = Time.now
|
27
|
-
#puts t.to_f
|
28
|
-
|
29
|
-
st = t.to_f * 1000 * 10
|
30
|
-
|
31
|
-
#puts st
|
32
|
-
|
33
|
-
st = Integer(st) % (10 * 1000 * 60 * 60)
|
34
|
-
#st = 28340469
|
35
|
-
|
36
|
-
s = Kotoba::from_integer(st)
|
37
|
-
|
38
|
-
st2 = Kotoba::to_integer(s)
|
39
|
-
s2 = Kotoba::from_integer(st2)
|
40
|
-
|
41
|
-
#puts st
|
42
|
-
#puts s
|
43
|
-
|
44
|
-
#puts st2
|
45
|
-
#puts s2
|
46
|
-
|
47
|
-
assert_equal s, s2
|
48
|
-
assert_equal st, st2
|
49
|
-
|
50
|
-
a = Kotoba::split(s)
|
51
|
-
|
52
|
-
assert_equal a.join, s
|
53
|
-
|
54
|
-
#puts Kotoba::to_integer("tunashima")
|
55
|
-
#puts Kotoba::to_integer("tsunashima")
|
56
|
-
|
57
|
-
assert Kotoba::is_kotoba_word("takeshi")
|
58
|
-
|
59
|
-
assert Kotoba::is_kotoba_word("tsunasima")
|
60
|
-
assert Kotoba::is_kotoba_word("tunashima")
|
61
|
-
|
62
|
-
assert (not Kotoba::is_kotoba_word("dsfadf"))
|
63
|
-
assert (not Kotoba::is_kotoba_word("takeshin"))
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
#require 'pp'
|
68
|
-
#pp Kotoba::split(s2)
|
69
|
-
#
|
70
|
-
#puts Kotoba::is_kotoba_word("asdfadsg")
|
71
|
-
#puts Kotoba::is_kotoba_word(s2)
|
72
|
-
|
data/test/lru_test.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Testing OpenWFE
|
4
|
-
#
|
5
|
-
# John Mettraux at openwfe.org
|
6
|
-
#
|
7
|
-
# Sun Oct 29 16:18:25 JST 2006
|
8
|
-
#
|
9
|
-
|
10
|
-
require 'test/unit'
|
11
|
-
require 'openwfe/util/lru'
|
12
|
-
|
13
|
-
include OpenWFE
|
14
|
-
|
15
|
-
|
16
|
-
#
|
17
|
-
# testing the lru hash things
|
18
|
-
#
|
19
|
-
|
20
|
-
class LruTest < Test::Unit::TestCase
|
21
|
-
|
22
|
-
#def setup
|
23
|
-
#end
|
24
|
-
|
25
|
-
#def teardown
|
26
|
-
#end
|
27
|
-
|
28
|
-
def test_lru_0
|
29
|
-
|
30
|
-
h = LruHash.new(3)
|
31
|
-
|
32
|
-
assert h.size == 0
|
33
|
-
|
34
|
-
h[:a] = "A"
|
35
|
-
|
36
|
-
assert h.size == 1
|
37
|
-
|
38
|
-
h[:b] = "B"
|
39
|
-
h[:c] = "C"
|
40
|
-
|
41
|
-
assert h.size == 3
|
42
|
-
assert h.ordered_keys == [ :a, :b, :c ]
|
43
|
-
|
44
|
-
h[:d] = "D"
|
45
|
-
|
46
|
-
assert h.size == 3
|
47
|
-
assert h.ordered_keys == [ :b, :c, :d ]
|
48
|
-
assert h[:a] == nil
|
49
|
-
assert h[:b] == "B"
|
50
|
-
assert h.ordered_keys == [ :c, :d, :b ]
|
51
|
-
|
52
|
-
h.delete(:d)
|
53
|
-
|
54
|
-
#require 'pp'
|
55
|
-
#puts "lru keys :"
|
56
|
-
#pp h.ordered_keys
|
57
|
-
|
58
|
-
assert h.size == 2
|
59
|
-
assert h.ordered_keys == [ :c, :b ]
|
60
|
-
|
61
|
-
h[:a] = "A"
|
62
|
-
|
63
|
-
assert h.size == 3
|
64
|
-
assert h.ordered_keys == [ :c, :b, :a ]
|
65
|
-
|
66
|
-
h[:d] = "D"
|
67
|
-
|
68
|
-
|
69
|
-
assert h.size == 3
|
70
|
-
assert h.ordered_keys == [ :b, :a, :d ]
|
71
|
-
|
72
|
-
assert h[:b] == "B"
|
73
|
-
assert h[:a] == "A"
|
74
|
-
assert h[:d] == "D"
|
75
|
-
assert h[:c] == nil
|
76
|
-
assert h.ordered_keys == [ :b, :a, :d ]
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
data/test/safely_test.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Testing OpenWFE
|
4
|
-
#
|
5
|
-
# John Mettraux at openwfe.org
|
6
|
-
#
|
7
|
-
|
8
|
-
require 'tempfile'
|
9
|
-
|
10
|
-
require 'test/unit'
|
11
|
-
require 'openwfe/util/safe'
|
12
|
-
|
13
|
-
|
14
|
-
class SafelyTest < Test::Unit::TestCase
|
15
|
-
|
16
|
-
#def setup
|
17
|
-
#end
|
18
|
-
|
19
|
-
#def teardown
|
20
|
-
#end
|
21
|
-
|
22
|
-
#def test_safely_0
|
23
|
-
# assert_not_nil dotest("print ''", 4)
|
24
|
-
# assert_not_nil dotest2("print ''", 4)
|
25
|
-
# assert_nil dotest("print ''", 2)
|
26
|
-
# assert_nil dotest2("print ''", 2)
|
27
|
-
#end
|
28
|
-
|
29
|
-
def test_safely_1
|
30
|
-
|
31
|
-
if OpenWFE::on_jruby?
|
32
|
-
puts
|
33
|
-
puts "skipping safe tests as JRuby doesn't support $SAFE levels..."
|
34
|
-
return
|
35
|
-
end
|
36
|
-
|
37
|
-
assert_not_nil dotest3(STDOUT, "self.print ''", 4)
|
38
|
-
assert_nil dotest3(STDOUT, "self.print ''", 2)
|
39
|
-
|
40
|
-
assert_not_nil dotest3(nil, "print ''", 4)
|
41
|
-
assert_nil dotest3(nil, "print ''", 2)
|
42
|
-
end
|
43
|
-
|
44
|
-
protected
|
45
|
-
|
46
|
-
#def dotest (code, level)
|
47
|
-
# tf = Tempfile.new "safely_test_temp.rb"
|
48
|
-
# tf.puts code
|
49
|
-
# tf.close
|
50
|
-
# e = nil
|
51
|
-
# begin
|
52
|
-
# OpenWFE::load_safely(tf.path, level)
|
53
|
-
# rescue Exception => e
|
54
|
-
# end
|
55
|
-
# File.delete(tf.path)
|
56
|
-
# e
|
57
|
-
#end
|
58
|
-
|
59
|
-
#def dotest2 (code, level)
|
60
|
-
# begin
|
61
|
-
# OpenWFE::load_eval_safely(code, level)
|
62
|
-
# rescue Exception => e
|
63
|
-
# return e
|
64
|
-
# end
|
65
|
-
# nil
|
66
|
-
#end
|
67
|
-
|
68
|
-
def dotest3 (instance, code, level)
|
69
|
-
|
70
|
-
begin
|
71
|
-
if instance
|
72
|
-
OpenWFE::instance_eval_safely(instance, code, level)
|
73
|
-
else
|
74
|
-
OpenWFE::eval_safely(code, level)
|
75
|
-
end
|
76
|
-
rescue Exception => e
|
77
|
-
return e
|
78
|
-
end
|
79
|
-
|
80
|
-
nil
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|