mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
expression: set floats as f64 by default
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
|
||||
fn test_fixed_array_can_be_assigned(){
|
||||
x := 2.32
|
||||
mut v := [8]f32
|
||||
mut v := [8]f64
|
||||
v = [1.0, x, 3.0,4.0,5.0,6.0,7.0,8.0]!!
|
||||
assert v[1] == x
|
||||
}
|
||||
@ -15,7 +15,7 @@ fn test_fixed_array_can_be_used_in_declaration(){
|
||||
|
||||
struct Context {
|
||||
pub mut:
|
||||
vb [8]f32
|
||||
vb [8]f64
|
||||
}
|
||||
fn test_fixed_array_can_be_assigned_to_a_struct_field(){
|
||||
mut ctx := Context{}
|
||||
|
@ -9,7 +9,7 @@ struct FunkyStruct{ }
|
||||
|
||||
fn test_nameof_on_various_types_in_generic() {
|
||||
assert simple(42) == "int"
|
||||
assert simple(3.14) == "f32"
|
||||
assert simple(3.14) == "f64"
|
||||
assert simple("FuBar") == "string"
|
||||
assert simple(FunkyStruct{}) == "FunkyStruct"
|
||||
assert simple(test_nameof_on_various_types_in_generic) == "fn ()"
|
||||
|
@ -6,9 +6,9 @@ type Myf64 f64
|
||||
fn test_type_alias() {
|
||||
i := Myint(10)
|
||||
assert i + 100 == 110
|
||||
|
||||
f := Myf32(1.0)
|
||||
assert f + 3.14 == 4.14
|
||||
|
||||
f := Myf64(10.4)
|
||||
assert f + 0.5 == 10.9
|
||||
|
||||
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
fn test_typeof_on_simple_expressions() {
|
||||
a := 123
|
||||
assert typeof(42) == 'int'
|
||||
assert typeof(3.14) == 'f32'
|
||||
assert typeof(3.14) == 'f64'
|
||||
assert typeof(2+2*10) == 'int'
|
||||
assert typeof(1.0 * 12.2) == 'f32'
|
||||
assert typeof(1.0 * 12.2) == 'f64'
|
||||
assert typeof(a) == 'int'
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ pub fn (ms MySumType) str() string {
|
||||
|
||||
fn test_typeof_on_sumtypes(){
|
||||
a := MySumType(32)
|
||||
b := MySumType(123.0)
|
||||
b := MySumType(f32(123.0))
|
||||
c := MySumType(FooBar{x:43})
|
||||
assert typeof(a) == 'int'
|
||||
assert typeof(b) == 'f32'
|
||||
@ -84,4 +84,4 @@ fn myfn2() {}
|
||||
fn test_typeof_on_fn() {
|
||||
assert typeof(myfn) == 'fn (int) int'
|
||||
assert typeof(myfn2) == 'fn ()'
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user