diff options
author | Araq <rumpf_a@web.de> | 2014-05-29 13:27:45 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-05-29 13:27:45 +0200 |
commit | 6470bd8f87b860c555556a2a965f6c8077e993ad (patch) | |
tree | a7003f0246bc58746b23f7112da1dc8d2c90add4 /tests/parallel | |
parent | f12a0820e0e7e5c32378bb56b8d0d2591fc71ae5 (diff) | |
download | Nim-6470bd8f87b860c555556a2a965f6c8077e993ad.tar.gz |
'parallel' proves array bounds
Diffstat (limited to 'tests/parallel')
-rw-r--r-- | tests/parallel/tforstmt.nim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/parallel/tforstmt.nim b/tests/parallel/tforstmt.nim new file mode 100644 index 000000000..35f28759e --- /dev/null +++ b/tests/parallel/tforstmt.nim @@ -0,0 +1,24 @@ +discard """ + output: '''3 +4 +5 +6 +7''' + sortoutput: true +""" + +import threadpool, math + +proc p(x: int) = + echo x + +proc testFor(a, b: int; foo: var openArray[int]) = + parallel: + for i in max(a, 0) .. min(b, foo.len-1): + spawn p(foo[i]) + +var arr = [0, 1, 2, 3, 4, 5, 6, 7] + +testFor(3, 10, arr) + + |