Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
pygolang
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
pygolang
Commits
617b51b2
Commit
617b51b2
authored
Jan 29, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync: tests: Move into sync_test.cpp from <- libgolang_test.cpp
parent
ff2ed5fe
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
29 deletions
+56
-29
MANIFEST.in
MANIFEST.in
+1
-0
golang/_golang_test.pyx
golang/_golang_test.pyx
+0
-5
golang/_sync_test.pyx
golang/_sync_test.pyx
+11
-0
golang/runtime/libgolang_test.cpp
golang/runtime/libgolang_test.cpp
+0
-23
golang/sync_test.cpp
golang/sync_test.cpp
+42
-0
setup.py
setup.py
+2
-1
No files found.
MANIFEST.in
View file @
617b51b2
...
@@ -16,6 +16,7 @@ include golang/strings.h
...
@@ -16,6 +16,7 @@ include golang/strings.h
include golang/strings.cpp
include golang/strings.cpp
include golang/sync.h
include golang/sync.h
include golang/sync.cpp
include golang/sync.cpp
include golang/sync_test.cpp
include golang/time.h
include golang/time.h
include golang/time.cpp
include golang/time.cpp
include golang/_testing.h
include golang/_testing.h
...
...
golang/_golang_test.pyx
View file @
617b51b2
...
@@ -235,7 +235,6 @@ cdef extern from * nogil:
...
@@ -235,7 +235,6 @@ cdef extern from * nogil:
extern void _test_strings_has_suffix();
extern void _test_strings_has_suffix();
extern void _test_strings_trim_suffix();
extern void _test_strings_trim_suffix();
extern void _test_strings_split();
extern void _test_strings_split();
extern void _test_sync_once_cpp();
"""
"""
void
_test_chan_cpp_refcount
()
except
+
topyexc
void
_test_chan_cpp_refcount
()
except
+
topyexc
void
_test_chan_cpp
()
except
+
topyexc
void
_test_chan_cpp
()
except
+
topyexc
...
@@ -255,7 +254,6 @@ cdef extern from * nogil:
...
@@ -255,7 +254,6 @@ cdef extern from * nogil:
void
_test_strings_has_suffix
()
except
+
topyexc
void
_test_strings_has_suffix
()
except
+
topyexc
void
_test_strings_trim_suffix
()
except
+
topyexc
void
_test_strings_trim_suffix
()
except
+
topyexc
void
_test_strings_split
()
except
+
topyexc
void
_test_strings_split
()
except
+
topyexc
void
_test_sync_once_cpp
()
except
+
topyexc
def
test_chan_cpp_refcount
():
def
test_chan_cpp_refcount
():
with
nogil
:
with
nogil
:
_test_chan_cpp_refcount
()
_test_chan_cpp_refcount
()
...
@@ -310,9 +308,6 @@ def test_strings_trim_suffix():
...
@@ -310,9 +308,6 @@ def test_strings_trim_suffix():
def
test_strings_split
():
def
test_strings_split
():
with
nogil
:
with
nogil
:
_test_strings_split
()
_test_strings_split
()
def
test_sync_once_cpp
():
# TODO move -> _sync_test.pyx
with
nogil
:
_test_sync_once_cpp
()
# helpers for pychan(dtype=X) py <-> c tests.
# helpers for pychan(dtype=X) py <-> c tests.
...
...
golang/_sync_test.pyx
View file @
617b51b2
...
@@ -174,3 +174,14 @@ cdef void _test_once() nogil except +topyexc:
...
@@ -174,3 +174,14 @@ cdef void _test_once() nogil except +topyexc:
def
test_once
():
def
test_once
():
with
nogil
:
with
nogil
:
_test_once
()
_test_once
()
# sync_test.cpp
cdef
extern
from
*
nogil
:
"""
extern void _test_sync_once_cpp();
"""
void
_test_sync_once_cpp
()
except
+
topyexc
def
test_sync_once_cpp
():
with
nogil
:
_test_sync_once_cpp
()
golang/runtime/libgolang_test.cpp
View file @
617b51b2
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#include "golang/libgolang.h"
#include "golang/libgolang.h"
#include "golang/fmt.h"
#include "golang/fmt.h"
#include "golang/strings.h"
#include "golang/strings.h"
#include "golang/sync.h"
#include "golang/time.h"
#include "golang/time.h"
#include <stdio.h>
#include <stdio.h>
...
@@ -800,25 +799,3 @@ void _test_strings_split() {
...
@@ -800,25 +799,3 @@ void _test_strings_split() {
ASSERT_EQ
(
strings
::
split
(
" ab cd e"
,
' '
)
,
V
({
""
,
"ab"
,
"cd"
,
"e"
}));
ASSERT_EQ
(
strings
::
split
(
" ab cd e"
,
' '
)
,
V
({
""
,
"ab"
,
"cd"
,
"e"
}));
ASSERT_EQ
(
strings
::
split
(
" ab cd e"
,
' '
)
,
V
({
""
,
""
,
"ab"
,
"cd"
,
"e"
}));
ASSERT_EQ
(
strings
::
split
(
" ab cd e"
,
' '
)
,
V
({
""
,
""
,
"ab"
,
"cd"
,
"e"
}));
}
}
// ---- sync:: ----
// verify that sync::Once works.
void
_test_sync_once_cpp
()
{
sync
::
Once
once
;
int
ncall
=
0
;
ASSERT
(
ncall
==
0
);
once
.
do_
([
&
]()
{
ncall
++
;
});
ASSERT
(
ncall
==
1
);
once
.
do_
([
&
]()
{
ncall
++
;
});
ASSERT
(
ncall
==
1
);
once
.
do_
([
&
]()
{
ncall
++
;
panic
(
"should not panic"
);
});
ASSERT
(
ncall
==
1
);
}
golang/sync_test.cpp
0 → 100644
View file @
617b51b2
// Copyright (C) 2019-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
#include "golang/sync.h"
#include "golang/_testing.h"
using
namespace
golang
;
// verify that sync::Once works.
void
_test_sync_once_cpp
()
{
sync
::
Once
once
;
int
ncall
=
0
;
ASSERT
(
ncall
==
0
);
once
.
do_
([
&
]()
{
ncall
++
;
});
ASSERT
(
ncall
==
1
);
once
.
do_
([
&
]()
{
ncall
++
;
});
ASSERT
(
ncall
==
1
);
once
.
do_
([
&
]()
{
ncall
++
;
panic
(
"should not panic"
);
});
ASSERT
(
ncall
==
1
);
}
setup.py
View file @
617b51b2
...
@@ -256,7 +256,8 @@ setup(
...
@@ -256,7 +256,8 @@ setup(
dsos
=
[
'golang.runtime.libpyxruntime'
],
dsos
=
[
'golang.runtime.libpyxruntime'
],
define_macros
=
[(
'_LIBGOLANG_SYNC_INTERNAL_API'
,
None
)]),
define_macros
=
[(
'_LIBGOLANG_SYNC_INTERNAL_API'
,
None
)]),
Ext
(
'golang._sync_test'
,
Ext
(
'golang._sync_test'
,
[
'golang/_sync_test.pyx'
]),
[
'golang/_sync_test.pyx'
,
'golang/sync_test.cpp'
]),
Ext
(
'golang._time'
,
Ext
(
'golang._time'
,
[
'golang/_time.pyx'
],
[
'golang/_time.pyx'
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment