From 4ca73eb66a57f32085be56c64ce316b82084602f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 25 Jan 2015 02:25:50 -0800 Subject: 620 - fix broken examples and tests again I just did this in 611; what's the point of all this if tests can't stay passing? I don't understand why buffered-stdin.mu needs to preempt itself. stdin and buffered-stdin somehow end up sharing a single circular buffer, that's probably causing a race condition. --- buffered-stdin.mu | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'buffered-stdin.mu') diff --git a/buffered-stdin.mu b/buffered-stdin.mu index 7db3e291..a0e39154 100644 --- a/buffered-stdin.mu +++ b/buffered-stdin.mu @@ -1,4 +1,4 @@ -; reads lines, prints when you hit 'enter' +; reads lines, prints them back when you hit 'enter' ; dies if you wait a while, because so far we never free memory (function main [ (default-space:space-address <- new space:literal 30:literal) @@ -10,18 +10,20 @@ ; buffer stdin (buffered-stdin:channel-address <- init-channel 1:literal) (fork-helper buffer-stdin:fn nil:literal/globals nil:literal/limit stdin:channel-address buffered-stdin:channel-address) - ; now read characters from the buffer until a 'enter' is typed - (s:string-address <- new "? ") - (print-string nil:literal/terminal s:string-address) { begin - (x:tagged-value stdin:channel-address/deref <- read buffered-stdin:channel-address) - (c:character <- maybe-coerce x:tagged-value character:literal) -;? (print-primitive-to-host (("AAA " literal))) ;? 0 -;? (print-primitive-to-host c:character) ;? 0 -;? (print-primitive-to-host (("\n" literal))) ;? 0 - (done?:boolean <- equal c:character ((#\newline literal))) - (break-if done?:boolean) - (print-character nil:literal/terminal c:character) + ; now read characters from the buffer until 'enter' is typed + (s:string-address <- new "? ") + (print-string nil:literal/terminal s:string-address) + { begin + (x:tagged-value stdin:channel-address/deref <- read buffered-stdin:channel-address) + (c:character <- maybe-coerce x:tagged-value character:literal) +;? (print-primitive-to-host (("AAA " literal))) ;? 1 +;? (print-primitive-to-host c:character) ;? 1 +;? (print-primitive-to-host (("\n" literal))) ;? 1 + (print-character nil:literal/terminal c:character) + (line-done?:boolean <- equal c:character ((#\newline literal))) + (loop-unless line-done?:boolean) + } (loop) } ]) -- cgit 1.4.1-2-gfad0 549e6576c680c0a023dce'>tests/unittests/helpers.c
blob: f57bded1a5220d5ce51414d80d9a7266f96b781a (plain) (blame)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133