~ubuntu-branches/ubuntu/vivid/cctools/vivid

« back to all changes in this revision

Viewing changes to ftsh/test/try.ftsh

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2011-05-07 09:05:00 UTC
  • Revision ID: james.westby@ubuntu.com-20110507090500-lqpmdtwndor6e7os
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#
 
3
# A really trivial try block
 
4
#
 
5
 
 
6
try for 10 seconds
 
7
        echo "Not too hard."
 
8
end
 
9
 
 
10
#
 
11
# This try should always succeed
 
12
#
 
13
 
 
14
try
 
15
        try for 10 seconds
 
16
                sleep 1
 
17
        end
 
18
        echo "Try did not expire, as expected."
 
19
catch
 
20
        echo "Try expired incorrectly!"
 
21
        failure
 
22
end
 
23
 
 
24
#
 
25
# This try should always fail
 
26
#
 
27
 
 
28
try
 
29
        try for 1 second
 
30
                sleep 10
 
31
        end
 
32
        echo "Try should not have succeeded!."
 
33
catch
 
34
        echo "Try failed as expected."
 
35
end
 
36
 
 
37
#
 
38
# This try should succeed after several times through
 
39
#
 
40
 
 
41
try
 
42
        tm=6
 
43
 
 
44
        try for 10 times
 
45
                newtm=${tm} .sub. 1
 
46
                tm=${newtm}
 
47
                try for 3 seconds
 
48
                        sleep ${tm}
 
49
                end
 
50
        end
 
51
        echo "Try eventually succeeded, as expected"
 
52
catch
 
53
        echo "Try failed unexpectedly."
 
54
        failure
 
55
end
 
56
 
 
57
#
 
58
# Test lots of variations on syntax
 
59
#
 
60
 
 
61
try 1 time 10 seconds
 
62
        echo "Testing"
 
63
end
 
64
 
 
65
try for 1 time 10 seconds
 
66
        echo "Testing"
 
67
end
 
68
 
 
69
try 1 time or 10 seconds
 
70
        echo "Testing"
 
71
end
 
72
 
 
73
try for 1 time or 10 seconds
 
74
        echo "Testing"
 
75
end
 
76
 
 
77
try 10 seconds 1 time
 
78
        echo "Testing"
 
79
end
 
80
 
 
81
try for 10 seconds 1 time
 
82
        echo "Testing"
 
83
end
 
84
 
 
85
try 10 seconds or 1 time
 
86
        echo "Testing"
 
87
end
 
88
 
 
89
try for 10 seconds or 1 time
 
90
        echo "Testing"
 
91
end
 
92
 
 
93
try for 10 seconds or 1 time
 
94
        echo "Testing"
 
95
end
 
96
 
 
97
try for 10 seconds or 1 time
 
98
        echo "Testing"
 
99
end
 
100
 
 
101
try 10 seconds or 1 time every 10 seconds
 
102
        echo "Testing"
 
103
end
 
104
 
 
105
try 1 time or 10 seconds every 10 seconds
 
106
        echo "Testing"
 
107
end