mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
fix tests
This commit is contained in:
parent
8b0445ebd7
commit
e34603165c
3 changed files with 195 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
// vtest vflags: -d new_1 -d new_a_2 -d new_b_3 -d new_c_1 -d new_d_2 -d new_e_3
|
||||
// vtest vflags: -d new_1 -d new_a_1 -d new_b_1 -d new_c_1 -d new_d_1 -d new_e_1
|
||||
module main
|
||||
|
||||
// this is comment, should skip
|
||||
|
@ -9,11 +9,11 @@ $if new_1 ? {
|
|||
// this is comment, should skip
|
||||
} $else $if new_2 ? {
|
||||
// this is comment, should skip
|
||||
import os
|
||||
import math
|
||||
// this is comment, should skip
|
||||
} $else {
|
||||
// this is comment, should skip
|
||||
import os
|
||||
import time
|
||||
// this is comment, should skip
|
||||
}
|
||||
// this is comment, should skip
|
||||
|
@ -41,19 +41,16 @@ $if new_c_1 ? {
|
|||
enum1_a
|
||||
enum1_b
|
||||
}
|
||||
|
||||
} $else $if new_c_2 ? {
|
||||
pub enum Enum1 {
|
||||
enum1_c
|
||||
enum1_d
|
||||
}
|
||||
|
||||
} $else {
|
||||
pub enum Enum1 {
|
||||
enum1_e
|
||||
enum1_f
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$if new_d_1 ? {
|
||||
|
@ -87,11 +84,11 @@ $if new_e_1 ? {
|
|||
fn test_main() {
|
||||
assert os.user_os().len > 0
|
||||
assert t in [1, 2]
|
||||
assert sizeof(Digits) == 4 // Digits == u32
|
||||
assert const1 == 1.1
|
||||
assert sizeof(Digits) == 8 // Digits == u64
|
||||
assert const1 == '123'
|
||||
_ := Enum1.enum1_a // should compile
|
||||
_ := Struct1{
|
||||
b: 123
|
||||
a: 123
|
||||
} // should compile
|
||||
assert ret() == 'new_e_3'
|
||||
assert ret() == 'new_e_1'
|
||||
}
|
94
vlib/v/tests/comptime/comptime_if_top_2_test.v
Normal file
94
vlib/v/tests/comptime/comptime_if_top_2_test.v
Normal file
|
@ -0,0 +1,94 @@
|
|||
// vtest vflags: -d new_2 -d new_a_2 -d new_b_2 -d new_c_2 -d new_d_2 -d new_e_2
|
||||
module main
|
||||
|
||||
// this is comment, should skip
|
||||
|
||||
$if new_1 ? {
|
||||
// this is comment, should skip
|
||||
import os
|
||||
// this is comment, should skip
|
||||
} $else $if new_2 ? {
|
||||
// this is comment, should skip
|
||||
import math
|
||||
// this is comment, should skip
|
||||
} $else {
|
||||
// this is comment, should skip
|
||||
import time
|
||||
// this is comment, should skip
|
||||
}
|
||||
// this is comment, should skip
|
||||
|
||||
const t = $if amd64 { 1 } $else { 2 }
|
||||
|
||||
$if new_a_1 ? {
|
||||
pub type Digits = u64
|
||||
} $else $if new_a_2 ? {
|
||||
pub type Digits = u32
|
||||
} $else {
|
||||
pub type Digits = u8
|
||||
}
|
||||
|
||||
$if new_b_1 ? {
|
||||
pub const const1 = '123'
|
||||
} $else $if new_b_2 ? {
|
||||
pub const const1 = 123
|
||||
} $else {
|
||||
pub const const1 = 1.1
|
||||
}
|
||||
|
||||
$if new_c_1 ? {
|
||||
pub enum Enum1 {
|
||||
enum1_a
|
||||
enum1_b
|
||||
}
|
||||
} $else $if new_c_2 ? {
|
||||
pub enum Enum1 {
|
||||
enum1_c
|
||||
enum1_d
|
||||
}
|
||||
} $else {
|
||||
pub enum Enum1 {
|
||||
enum1_e
|
||||
enum1_f
|
||||
}
|
||||
}
|
||||
|
||||
$if new_d_1 ? {
|
||||
pub struct Struct1 {
|
||||
a int
|
||||
}
|
||||
} $else $if new_d_2 ? {
|
||||
pub struct Struct1 {
|
||||
b int
|
||||
}
|
||||
} $else {
|
||||
pub struct Struct1 {
|
||||
c int
|
||||
}
|
||||
}
|
||||
|
||||
$if new_e_1 ? {
|
||||
pub fn ret() string {
|
||||
return 'new_e_1'
|
||||
}
|
||||
} $else $if new_e_2 ? {
|
||||
pub fn ret() string {
|
||||
return 'new_e_2'
|
||||
}
|
||||
} $else {
|
||||
pub fn ret() string {
|
||||
return 'new_e_3'
|
||||
}
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
assert math.max(1, 2) == 2
|
||||
assert t in [1, 2]
|
||||
assert sizeof(Digits) == 4 // Digits == u32
|
||||
assert const1 == 123
|
||||
_ := Enum1.enum1_d // should compile
|
||||
_ := Struct1{
|
||||
b: 123
|
||||
} // should compile
|
||||
assert ret() == 'new_e_2'
|
||||
}
|
94
vlib/v/tests/comptime/comptime_if_top_3_test.v
Normal file
94
vlib/v/tests/comptime/comptime_if_top_3_test.v
Normal file
|
@ -0,0 +1,94 @@
|
|||
// vtest vflags: -d new_3 -d new_a_3 -d new_b_3 -d new_c_3 -d new_d_3 -d new_e_3
|
||||
module main
|
||||
|
||||
// this is comment, should skip
|
||||
|
||||
$if new_1 ? {
|
||||
// this is comment, should skip
|
||||
import os
|
||||
// this is comment, should skip
|
||||
} $else $if new_2 ? {
|
||||
// this is comment, should skip
|
||||
import math
|
||||
// this is comment, should skip
|
||||
} $else {
|
||||
// this is comment, should skip
|
||||
import time
|
||||
// this is comment, should skip
|
||||
}
|
||||
// this is comment, should skip
|
||||
|
||||
const t = $if amd64 { 1 } $else { 2 }
|
||||
|
||||
$if new_a_1 ? {
|
||||
pub type Digits = u64
|
||||
} $else $if new_a_2 ? {
|
||||
pub type Digits = u32
|
||||
} $else {
|
||||
pub type Digits = u8
|
||||
}
|
||||
|
||||
$if new_b_1 ? {
|
||||
pub const const1 = '123'
|
||||
} $else $if new_b_2 ? {
|
||||
pub const const1 = 123
|
||||
} $else {
|
||||
pub const const1 = 1.1
|
||||
}
|
||||
|
||||
$if new_c_1 ? {
|
||||
pub enum Enum1 {
|
||||
enum1_a
|
||||
enum1_b
|
||||
}
|
||||
} $else $if new_c_2 ? {
|
||||
pub enum Enum1 {
|
||||
enum1_c
|
||||
enum1_d
|
||||
}
|
||||
} $else {
|
||||
pub enum Enum1 {
|
||||
enum1_e
|
||||
enum1_f
|
||||
}
|
||||
}
|
||||
|
||||
$if new_d_1 ? {
|
||||
pub struct Struct1 {
|
||||
a int
|
||||
}
|
||||
} $else $if new_d_2 ? {
|
||||
pub struct Struct1 {
|
||||
b int
|
||||
}
|
||||
} $else {
|
||||
pub struct Struct1 {
|
||||
c int
|
||||
}
|
||||
}
|
||||
|
||||
$if new_e_1 ? {
|
||||
pub fn ret() string {
|
||||
return 'new_e_1'
|
||||
}
|
||||
} $else $if new_e_2 ? {
|
||||
pub fn ret() string {
|
||||
return 'new_e_2'
|
||||
}
|
||||
} $else {
|
||||
pub fn ret() string {
|
||||
return 'new_e_3'
|
||||
}
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
assert time.days_in_year == 365
|
||||
assert t in [1, 2]
|
||||
assert sizeof(Digits) == 1 // Digits == u8
|
||||
assert const1 == 1.1
|
||||
_ := Enum1.enum1_e // should compile
|
||||
_ := Struct1{
|
||||
c: 123
|
||||
} // should compile
|
||||
assert ret() == 'new_e_3'
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue