summary refs log tree commit diff stats
path: root/tests/bind
diff options
context:
space:
mode:
authorMiran <narimiran@users.noreply.github.com>2018-10-12 17:02:46 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-10-12 17:02:46 +0200
commit7f18d7cbc1fc8ad87c389b8d4d873e1d1169f794 (patch)
tree8c4839495fd6fc10376dc44cc8f9c7e3c625d18f /tests/bind
parentd2b04a8bc7a78845d25e8b789184ae54e98073ec (diff)
downloadNim-7f18d7cbc1fc8ad87c389b8d4d873e1d1169f794.tar.gz
Merge tests into a larger file (part 1 of ∞) (#9318)
* merge actiontable tests

* merge arithm tests

* merge array tests

* merge assign tests

* merge bind tests

* merge casestmt tests

* merge closure tests

* merge cnt seq tests

* merge collections tests

* merge concept issues tests

* merge concept tests

* fix failing tests

* smaller outputs

Use `doAssert` where possible.

* fix wrong output

* split `tcomputedgoto`

* revert merging concepts

* fix failing test
Diffstat (limited to 'tests/bind')
-rw-r--r--tests/bind/tbind.nim69
-rw-r--r--tests/bind/tbind1.nim21
-rw-r--r--tests/bind/tbind3.nim11
-rw-r--r--tests/bind/tbindoverload.nim12
-rw-r--r--tests/bind/tmixin.nim27
5 files changed, 69 insertions, 71 deletions
diff --git a/tests/bind/tbind.nim b/tests/bind/tbind.nim
new file mode 100644
index 000000000..6fcf95433
--- /dev/null
+++ b/tests/bind/tbind.nim
@@ -0,0 +1,69 @@
+discard """
+  file: "tbind.nim"
+  output:
+'''
+3
+1
+1
+1
+'''
+"""
+
+
+block tbind:
+# Test the new ``bind`` keyword for templates
+
+  proc p1(x: int8, y: int): int = return x + y
+
+  template tempBind(x, y): untyped =
+    bind p1
+    p1(x, y)
+
+  proc p1(x: int, y: int8): int = return x - y
+
+  # This is tricky: the call to ``p1(1'i8, 2'i8)`` should not fail in line 6,
+  # because it is not ambiguous there. But it is ambiguous after line 8.
+
+  echo tempBind(1'i8, 2'i8) #OUT 3
+
+
+import mbind3
+echo genId() #OUT 1
+
+
+import strtabs
+block tbinoverload:
+  template t() =
+    block:
+      bind newStringTable
+      discard {"Content-Type": "text/html"}.newStringTable()
+
+      discard {:}.newStringTable
+  #discard {"Content-Type": "text/html"}.newStringTable()
+  t()
+
+
+block tmixin:
+  type
+    TFoo1 = object of RootObj
+      v: int
+    TFoo2 = object of TFoo1
+      v2: int
+
+  proc test(f: TFoo1) =
+    echo "1"
+
+  proc Foo[T](f: T) =
+    mixin test
+    test(f)
+
+  var
+    a: TFoo1
+    b: TFoo2
+
+
+  proc test(f: TFoo2) =
+    echo "2"
+
+  Foo(a)
+  Foo(b)
diff --git a/tests/bind/tbind1.nim b/tests/bind/tbind1.nim
deleted file mode 100644
index 9b13a7d11..000000000
--- a/tests/bind/tbind1.nim
+++ /dev/null
@@ -1,21 +0,0 @@
-discard """
-  file: "tbind1.nim"
-  output: "3"
-"""
-# Test the new ``bind`` keyword for templates
-
-proc p1(x: int8, y: int): int = return x + y
-
-template tempBind(x, y): untyped =
-  bind p1
-  p1(x, y)
-
-proc p1(x: int, y: int8): int = return x - y
-
-# This is tricky: the call to ``p1(1'i8, 2'i8)`` should not fail in line 6,
-# because it is not ambiguous there. But it is ambiguous after line 8.
-
-echo tempBind(1'i8, 2'i8) #OUT 3
-
-
-
diff --git a/tests/bind/tbind3.nim b/tests/bind/tbind3.nim
deleted file mode 100644
index 551acc10f..000000000
--- a/tests/bind/tbind3.nim
+++ /dev/null
@@ -1,11 +0,0 @@
-discard """
-  file: "tbind3.nim"
-  output: "1"
-"""
-# Module B
-import mbind3
-
-echo genId() #OUT 1
-
-
-
diff --git a/tests/bind/tbindoverload.nim b/tests/bind/tbindoverload.nim
deleted file mode 100644
index 6f5bb339e..000000000
--- a/tests/bind/tbindoverload.nim
+++ /dev/null
@@ -1,12 +0,0 @@
-import strtabs
-
-template t*() =
-  block:
-    bind newStringTable
-    discard {"Content-Type": "text/html"}.newStringTable()
-
-    discard {:}.newStringTable
-
-#discard {"Content-Type": "text/html"}.newStringTable()
-
-t()
diff --git a/tests/bind/tmixin.nim b/tests/bind/tmixin.nim
deleted file mode 100644
index 65c650261..000000000
--- a/tests/bind/tmixin.nim
+++ /dev/null
@@ -1,27 +0,0 @@
-discard """
-  output: "1\n2"
-"""
-
-type
-  TFoo1 = object of RootObj
-    v: int
-  TFoo2 = object of TFoo1
-    v2: int
-
-proc test(f: TFoo1) =
-  echo "1"
-
-proc Foo[T](f: T) =
-  mixin test
-  test(f)
-
-var
-  a: TFoo1
-  b: TFoo2
-
-
-proc test(f: TFoo2) =
-  echo "2"
-
-Foo(a)
-Foo(b)
;rumpf_a@web.de> 2018-12-09 13:47:03 +0100 committer Araq <rumpf_a@web.de> 2018-12-11 21:23:24 +0100 testament: joinable is now an explicit concept of a test spec' href='/ahoang/Nim/commit/testament/specs.nim?h=devel&id=ac785b06236dbc228a3b755c11bb3b1330ccc3ab'>ac785b062 ^
20b5f31c0 ^
199018ef2 ^
1f7dcb874 ^
20b5f31c0 ^








9c2365d5c ^
fa6a9a21e ^

3859878db ^
505836385 ^
2240fd3f3 ^

505836385 ^
20b5f31c0 ^

39aef1244 ^
20b5f31c0 ^
90808877c ^
20b5f31c0 ^
cdedb8634 ^
335c19c86 ^
199018ef2 ^
ac785b062 ^
90808877c ^
89a15e417 ^


223e65e52 ^
c9f3a8b26 ^

20b5f31c0 ^
3b783f7e1 ^





20b5f31c0 ^
7e9cda7db ^
2fb5d6292 ^
20b5f31c0 ^
dfe51d10a ^






4ab56d6be ^
20b5f31c0 ^




16b15f360 ^
20b5f31c0 ^















25abb7c2b ^
18508cdcc ^
25abb7c2b ^






a5ecbf823 ^
199018ef2 ^


a5ecbf823 ^
199018ef2 ^



c8cffaf42 ^


90808877c ^





6725aa363 ^
6725aa363 ^
da78c3d04 ^


b26378a46 ^














199018ef2 ^
b26378a46 ^
1105d0364 ^

b26378a46 ^

1105d0364 ^

b26378a46 ^

1105d0364 ^

b26378a46 ^







83a736a34 ^

3859878db ^
b26378a46 ^



3859878db ^
b26378a46 ^
199018ef2 ^



b26378a46 ^











90808877c ^

ac785b062 ^

223e65e52 ^



83a736a34 ^

223e65e52 ^



b26378a46 ^

ac785b062 ^
b26378a46 ^

ac785b062 ^
b26378a46 ^
ac785b062 ^
b26378a46 ^
ac785b062 ^
b26378a46 ^
ac785b062 ^
b26378a46 ^
ac785b062 ^
b26378a46 ^
ac785b062 ^
b26378a46 ^
ac785b062 ^
b26378a46 ^
ac785b062 ^
acebcd789 ^

28394153a ^


c5c6bae2a ^

d245d4cf0 ^

76ffa4fa2 ^

782819982 ^

123f9fb77 ^

b26378a46 ^
199018ef2 ^
b26378a46 ^








c9f3a8b26 ^




b26378a46 ^











199018ef2 ^
cdedb8634 ^


76c8d6164 ^
199018ef2 ^







b26378a46 ^


3d9269195 ^


90808877c ^



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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325