mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
testing: support for internal module testing
This commit is contained in:

committed by
Alexander Medvednikov

parent
3a2c46a1ce
commit
1cd5fab21d
@ -0,0 +1,16 @@
|
||||
module amodule
|
||||
|
||||
// This tests whether _test.v files can be *internal* to a
|
||||
// module, and thus have access to its guts.
|
||||
|
||||
// NB: the function test_private_isub() is defined both here
|
||||
// and inside internal_module_test.v . That is done on purpose,
|
||||
// with the goal of ensuring that _test.v files are compiled
|
||||
// *independently* from each other.
|
||||
//
|
||||
// _test.v files should *only* import all the other normal .v
|
||||
// files from the same folder, NOT other _test.v files from it.
|
||||
|
||||
fn test_private_isub(){
|
||||
assert private_isub(7,5) == 2
|
||||
}
|
16
vlib/compiler/tests/modules/amodule/internal_module_test.v
Normal file
16
vlib/compiler/tests/modules/amodule/internal_module_test.v
Normal file
@ -0,0 +1,16 @@
|
||||
module amodule
|
||||
|
||||
// this tests whether _test.v files can be *internal*
|
||||
// to a module, and thus have access to its guts.
|
||||
|
||||
fn test_iadd(){
|
||||
assert iadd(10, 20) == 30
|
||||
}
|
||||
|
||||
fn test_imul(){
|
||||
assert imul(5,8) == 40
|
||||
}
|
||||
|
||||
fn test_private_isub(){
|
||||
assert private_isub(10,6) == 4
|
||||
}
|
15
vlib/compiler/tests/modules/amodule/module.v
Normal file
15
vlib/compiler/tests/modules/amodule/module.v
Normal file
@ -0,0 +1,15 @@
|
||||
module amodule
|
||||
|
||||
pub fn iadd(x int, y int) int {
|
||||
return x + y
|
||||
}
|
||||
|
||||
pub fn imul(x int, y int) int {
|
||||
return x * y
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
fn private_isub(x int, y int) int {
|
||||
return x - y
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
module main
|
||||
|
||||
import os
|
||||
import compiler.tests.repl.runner
|
||||
import benchmark
|
||||
|
Reference in New Issue
Block a user