Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
ContenT
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ContenT
Commits
2abf5fbb
Commit
2abf5fbb
authored
Feb 16, 2026
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for compile-time method validation
parent
ec4a018f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
+97
-0
test_integration.py
tests/test_integration.py
+97
-0
No files found.
tests/test_integration.py
View file @
2abf5fbb
...
...
@@ -47,6 +47,28 @@ def compile_ct(source: str) -> tuple[int, str, str]:
os
.
unlink
(
ct_file
)
def
compile_ct_check
(
source
:
str
)
->
tuple
[
int
,
str
,
str
]:
with
tempfile
.
NamedTemporaryFile
(
mode
=
'w'
,
suffix
=
'.ct'
,
delete
=
False
)
as
f
:
f
.
write
(
source
)
f
.
flush
()
ct_file
=
f
.
name
sh_file
=
ct_file
.
replace
(
'.ct'
,
'.sh'
)
try
:
result
=
subprocess
.
run
(
[
'python3'
,
'content'
,
'build'
,
ct_file
,
'-o'
,
sh_file
],
capture_output
=
True
,
text
=
True
,
timeout
=
10
)
if
os
.
path
.
exists
(
sh_file
):
os
.
unlink
(
sh_file
)
return
result
.
returncode
,
result
.
stdout
,
result
.
stderr
finally
:
os
.
unlink
(
ct_file
)
class
TestPrint
:
def
test_print_string
(
self
):
code
,
stdout
,
_
=
run_ct
(
'print ("hello")'
)
...
...
@@ -806,3 +828,78 @@ func double(x) {
print(double(-1))
'''
)
assert
code
!=
0
or
"must be"
in
stderr
class
TestMethodValidation
:
def
test_unknown_array_method
(
self
):
code
,
stdout
,
stderr
=
compile_ct_check
(
'''
arr = [1, 2, 3]
x = arr.nonexistent()
'''
)
assert
code
!=
0
assert
"Unknown method 'nonexistent'"
in
stdout
assert
"array"
in
stdout
def
test_unknown_dict_method
(
self
):
code
,
stdout
,
stderr
=
compile_ct_check
(
'''
d = {"key": "value"}
x = d.nonexistent()
'''
)
assert
code
!=
0
assert
"Unknown method 'nonexistent'"
in
stdout
assert
"dict"
in
stdout
def
test_unknown_namespace_method
(
self
):
code
,
stdout
,
stderr
=
compile_ct_check
(
'''
x = fs.nonexistent()
'''
)
assert
code
!=
0
assert
"Unknown method 'nonexistent'"
in
stdout
assert
"fs"
in
stdout
def
test_valid_string_methods
(
self
):
code
,
stdout
,
stderr
=
compile_ct_check
(
'''
text = "hello"
a = text.upper()
b = text.lower()
c = text.len()
d = text.trim()
'''
)
assert
code
==
0
def
test_valid_array_methods
(
self
):
code
,
stdout
,
stderr
=
compile_ct_check
(
'''
arr = [1, 2, 3]
arr.push(4)
x = arr.pop()
y = arr.len()
z = arr.join(" ")
'''
)
assert
code
==
0
def
test_valid_dict_methods
(
self
):
code
,
stdout
,
stderr
=
compile_ct_check
(
'''
d = {"key": "value"}
a = d.get("key")
d.set("key2", "val2")
b = d.has("key")
c = d.keys()
'''
)
assert
code
==
0
def
test_valid_namespace_methods
(
self
):
code
,
stdout
,
stderr
=
compile_ct_check
(
'''
x = math.abs(-5)
y = math.max(1, 2)
'''
)
assert
code
==
0
def
test_error_shows_available_methods
(
self
):
code
,
stdout
,
stderr
=
compile_ct_check
(
'''
arr = [1, 2, 3]
x = arr.foo()
'''
)
assert
code
!=
0
assert
"Available:"
in
stdout
assert
"push"
in
stdout
assert
"pop"
in
stdout
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