-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmemory_leak.feature
86 lines (69 loc) · 1.74 KB
/
memory_leak.feature
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
Feature: Memory leak
Background:
Given an executable named "leak_memory.sh" with:
"""
#!/bin/sh
set -e
cloe $1 > /dev/null &
pid=$!
sleep 2 # Wait for memory usage to be stable.
ok=false
last_mem=0
for _ in $(seq 10)
do
mem=$(ps ho rss $pid)
if [ $last_mem -ge $mem ]
then
ok=true
break
fi
last_mem=$mem
sleep 1
done
kill $pid
$ok
"""
Scenario: Run infinite effects
This test succeeds only with Go 1.8 onward because of argument liveness.
Given a file named "main.cloe" with:
"""
(def (f) [(print 42) ..(f)])
..(f)
"""
When I run `sh leak_memory.sh main.cloe`
Then the exit status should be 0
Scenario: Evaluate deep recursion
Given a file named "main.cloe" with:
"""
(def (f n)
(match n
0 "OK!"
_ (f (- n 1))))
(print (f 100000000))
"""
When I run `sh leak_memory.sh main.cloe`
Then the exit status should be 0
Scenario: Apply a map function to an infinite list
Given a file named "main.cloe" with:
"""
(def (f) [42 ..(f)])
..(map print (f))
"""
When I run `sh leak_memory.sh main.cloe`
Then the exit status should be 0
Scenario: Apply a map function to an infinite list of map functions
Given a file named "main.cloe" with:
"""
(def (f) [map ..(f)])
..(map (\ (x) (print (typeOf x))) (f))
"""
When I run `sh leak_memory.sh main.cloe`
Then the exit status should be 0
Scenario: Apply max function to an infinite list
Given a file named "main.cloe" with:
"""
(def (f) [42 ..(f)])
(print (max ..(f)))
"""
When I run `sh leak_memory.sh main.cloe`
Then the exit status should be 0