Skip to content

Commit 8ee9b86

Browse files
committed
tests: Add a test to show contracts in parallel execution
Signed-off-by: Delja <deljarry.florian@gmail.com>
1 parent a441e15 commit 8ee9b86

3 files changed

Lines changed: 60 additions & 19 deletions

File tree

.gitlab-ci.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -427,25 +427,6 @@ build_catalog:
427427
paths:
428428
- catalog.out
429429

430-
build_tools_macos:
431-
<<: *build_tools
432-
tags:
433-
- macos
434-
435-
test_some_macos:
436-
<<: *test_some
437-
tags:
438-
- macos
439-
dependencies:
440-
- build_tools_macos
441-
442-
test_full_nitcs_macos:
443-
<<: *test_full_nitcs
444-
tags:
445-
- macos
446-
dependencies:
447-
- build_tools_macos
448-
449430
bench_old:
450431
stage: more_test
451432
tags:

tests/contracts_threaded.nit

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This file is part of NIT ( http://www.nitlanguage.org ).
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This test shows the verification of contracts in a parallel execution.
16+
17+
import pthreads
18+
19+
fun foo is
20+
threaded
21+
expect(contract_foo)
22+
do
23+
print "Foo"
24+
bar("Foo thread")
25+
end
26+
27+
fun bar(thread_name: String)
28+
is
29+
threaded
30+
expect(contract_bar(thread_name))
31+
do
32+
sys.nanosleep(3,0)
33+
print "Bar called from {thread_name}"
34+
end
35+
36+
fun contract_foo: Bool
37+
do
38+
sys.nanosleep(1,0)
39+
print("Foo contract")
40+
return true
41+
end
42+
43+
fun contract_bar(thread_name: String): Bool
44+
do
45+
sys.nanosleep(2,0)
46+
print("Bar contract called from {thread_name}")
47+
sys.nanosleep(1,0)
48+
return true
49+
end
50+
51+
52+
foo
53+
bar("Main thread")
54+
sys.nanosleep(5,0)

tests/sav/contracts_threaded.res

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Foo contract
2+
Foo
3+
Bar contract called from Foo thread
4+
Bar contract called from Main thread
5+
Bar called from Foo thread
6+
Bar called from Main thread

0 commit comments

Comments
 (0)