mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: change [1,2,3]!!
to [1,2,3]!
(#8101)
This commit is contained in:
parent
c8bcee9639
commit
a2efb5319d
@ -124,10 +124,10 @@ fn read_wav_file_samples(fpath string) ?[]f32 {
|
|||||||
mut offset := u32(0)
|
mut offset := u32(0)
|
||||||
rh := &RIFFHeader(pbytes)
|
rh := &RIFFHeader(pbytes)
|
||||||
// eprintln('rh: $rh')
|
// eprintln('rh: $rh')
|
||||||
if rh.riff != [byte(`R`), `I`, `F`, `F`]!! {
|
if rh.riff != [byte(`R`), `I`, `F`, `F`]! {
|
||||||
return error('WAV should start with `RIFF`')
|
return error('WAV should start with `RIFF`')
|
||||||
}
|
}
|
||||||
if rh.form_type != [byte(`W`), `A`, `V`, `E`]!! {
|
if rh.form_type != [byte(`W`), `A`, `V`, `E`]! {
|
||||||
return error('WAV should have `WAVE` form type')
|
return error('WAV should have `WAVE` form type')
|
||||||
}
|
}
|
||||||
if rh.file_size + 8 != bytes.len {
|
if rh.file_size + 8 != bytes.len {
|
||||||
@ -145,15 +145,15 @@ fn read_wav_file_samples(fpath string) ?[]f32 {
|
|||||||
// eprintln('ch: $ch')
|
// eprintln('ch: $ch')
|
||||||
// eprintln('p: $pbytes | offset: $offset | bytes.len: $bytes.len')
|
// eprintln('p: $pbytes | offset: $offset | bytes.len: $bytes.len')
|
||||||
// ////////
|
// ////////
|
||||||
if ch.chunk_type == [byte(`L`), `I`, `S`, `T`]!! {
|
if ch.chunk_type == [byte(`L`), `I`, `S`, `T`]! {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if ch.chunk_type == [byte(`i`), `d`, `3`, ` `]!! {
|
if ch.chunk_type == [byte(`i`), `d`, `3`, ` `]! {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if ch.chunk_type == [byte(`f`), `m`, `t`, ` `]!! {
|
if ch.chunk_type == [byte(`f`), `m`, `t`, ` `]! {
|
||||||
// eprintln('`fmt ` chunk')
|
// eprintln('`fmt ` chunk')
|
||||||
rf = &RIFFFormat(&ch.chunk_data)
|
rf = &RIFFFormat(&ch.chunk_data)
|
||||||
// eprintln('fmt riff format: $rf')
|
// eprintln('fmt riff format: $rf')
|
||||||
@ -169,7 +169,7 @@ fn read_wav_file_samples(fpath string) ?[]f32 {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if ch.chunk_type == [byte(`d`), `a`, `t`, `a`]!! {
|
if ch.chunk_type == [byte(`d`), `a`, `t`, `a`]! {
|
||||||
if rf == 0 {
|
if rf == 0 {
|
||||||
return error('`data` chunk should be after `fmt ` chunk')
|
return error('`data` chunk should be after `fmt ` chunk')
|
||||||
}
|
}
|
||||||
|
@ -12,37 +12,37 @@ fn test_eq() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_fixed_array_eq() {
|
fn test_fixed_array_eq() {
|
||||||
a1 := [1, 2, 3]!!
|
a1 := [1, 2, 3]!
|
||||||
assert a1 == [1, 2, 3]!!
|
assert a1 == [1, 2, 3]!
|
||||||
assert a1 != [2, 3, 4]!!
|
assert a1 != [2, 3, 4]!
|
||||||
|
|
||||||
a2 := [[1, 2]!!, [3, 4]!!]!!
|
a2 := [[1, 2]!, [3, 4]!]!
|
||||||
assert a2 == [[1, 2]!!, [3, 4]!!]!!
|
assert a2 == [[1, 2]!, [3, 4]!]!
|
||||||
assert a2 != [[3, 4]!!, [1, 2]!!]!!
|
assert a2 != [[3, 4]!, [1, 2]!]!
|
||||||
|
|
||||||
a3 := [[1, 2], [3, 4]]!!
|
a3 := [[1, 2], [3, 4]]!
|
||||||
assert a3 == [[1, 2], [3, 4]]!!
|
assert a3 == [[1, 2], [3, 4]]!
|
||||||
assert a3 != [[1, 1], [2, 2]]!!
|
assert a3 != [[1, 1], [2, 2]]!
|
||||||
|
|
||||||
a4 := [[`a`, `b`], [`c`, `d`]]!!
|
a4 := [[`a`, `b`], [`c`, `d`]]!
|
||||||
assert a4 == [[`a`, `b`], [`c`, `d`]]!!
|
assert a4 == [[`a`, `b`], [`c`, `d`]]!
|
||||||
assert a4 != [[`c`, `a`], [`a`, `b`]]!!
|
assert a4 != [[`c`, `a`], [`a`, `b`]]!
|
||||||
|
|
||||||
a5 := [['aaa', 'bbb'], ['ccc', 'ddd']]!!
|
a5 := [['aaa', 'bbb'], ['ccc', 'ddd']]!
|
||||||
assert a5 == [['aaa', 'bbb'], ['ccc', 'ddd']]!!
|
assert a5 == [['aaa', 'bbb'], ['ccc', 'ddd']]!
|
||||||
assert a5 != [['abc', 'def'], ['ccc', 'ddd']]!!
|
assert a5 != [['abc', 'def'], ['ccc', 'ddd']]!
|
||||||
|
|
||||||
a6 := [['aaa', 'bbb']!!, ['ccc', 'ddd']!!]!!
|
a6 := [['aaa', 'bbb']!, ['ccc', 'ddd']!]!
|
||||||
assert a6 == [['aaa', 'bbb']!!, ['ccc', 'ddd']!!]!!
|
assert a6 == [['aaa', 'bbb']!, ['ccc', 'ddd']!]!
|
||||||
assert a6 != [['aaa', 'bbb']!!, ['aaa', 'ddd']!!]!!
|
assert a6 != [['aaa', 'bbb']!, ['aaa', 'ddd']!]!
|
||||||
|
|
||||||
a7 := [[1, 2]!!, [3, 4]!!]
|
a7 := [[1, 2]!, [3, 4]!]
|
||||||
assert a7 == [[1, 2]!!, [3, 4]!!]
|
assert a7 == [[1, 2]!, [3, 4]!]
|
||||||
assert a7 != [[2, 3]!!, [1, 2]!!]
|
assert a7 != [[2, 3]!, [1, 2]!]
|
||||||
|
|
||||||
a8 := [['aaa', 'bbb']!!, ['ccc', 'ddd']!!]
|
a8 := [['aaa', 'bbb']!, ['ccc', 'ddd']!]
|
||||||
assert a8 == [['aaa', 'bbb']!!, ['ccc', 'ddd']!!]
|
assert a8 == [['aaa', 'bbb']!, ['ccc', 'ddd']!]
|
||||||
assert a8 != [['bbb', 'aaa']!!, ['cccc', 'dddd']!!]
|
assert a8 != [['bbb', 'aaa']!, ['cccc', 'dddd']!]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_fixed_array_literal_eq() {
|
fn test_fixed_array_literal_eq() {
|
||||||
@ -54,7 +54,7 @@ fn test_fixed_array_literal_eq() {
|
|||||||
|
|
||||||
assert [[1, 1]!, [2, 2]!]! == [[1, 1]!, [2, 2]!]!
|
assert [[1, 1]!, [2, 2]!]! == [[1, 1]!, [2, 2]!]!
|
||||||
assert [[1, 1]!, [2, 2]!]! != [[1, 2]!, [2, 3]!]!
|
assert [[1, 1]!, [2, 2]!]! != [[1, 2]!, [2, 3]!]!
|
||||||
|
|
||||||
assert [[1, 1]!, [2, 2]!] == [[1, 1]!, [2, 2]!]
|
assert [[1, 1]!, [2, 2]!] == [[1, 1]!, [2, 2]!]
|
||||||
assert [[1, 1]!, [2, 2]!] != [[1, 2]!, [2, 3]!]
|
assert [[1, 1]!, [2, 2]!] != [[1, 2]!, [2, 3]!]
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ const (
|
|||||||
0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||||
17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 63, 0, 26, 27, 28, 29,
|
17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 63, 0, 26, 27, 28, 29,
|
||||||
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
|
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
|
||||||
47, 48, 49, 50, 51]!!
|
47, 48, 49, 50, 51]!
|
||||||
|
|
||||||
ending_table = [0, 2, 1]!!
|
ending_table = [0, 2, 1]!
|
||||||
enc_table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
enc_table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
module ui
|
module ui
|
||||||
|
|
||||||
const (
|
const (
|
||||||
value_range = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff]!!
|
value_range = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff]!
|
||||||
color_table = init_color_table()
|
color_table = init_color_table()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -891,7 +891,7 @@ pub:
|
|||||||
exprs []Expr // `[expr, expr]` or `[expr]Type{}` for fixed array
|
exprs []Expr // `[expr, expr]` or `[expr]Type{}` for fixed array
|
||||||
ecmnts [][]Comment // optional iembed comments after each expr
|
ecmnts [][]Comment // optional iembed comments after each expr
|
||||||
is_fixed bool
|
is_fixed bool
|
||||||
has_val bool // fixed size literal `[expr, expr]!!`
|
has_val bool // fixed size literal `[expr, expr]!`
|
||||||
mod string
|
mod string
|
||||||
len_expr Expr // len: expr
|
len_expr Expr // len: expr
|
||||||
cap_expr Expr // cap: expr
|
cap_expr Expr // cap: expr
|
||||||
|
@ -111,11 +111,11 @@ println(cc)
|
|||||||
println(dd)
|
println(dd)
|
||||||
|
|
||||||
// fixed arrays: implemented as normal arrays
|
// fixed arrays: implemented as normal arrays
|
||||||
f1 := [1, 2, 3, 4, 5]!!
|
f1 := [1, 2, 3, 4, 5]!
|
||||||
mut f2 := [8]f32
|
mut f2 := [8]f32
|
||||||
f2[0] = f32(1.23)
|
f2[0] = f32(1.23)
|
||||||
f3 := ['foo', 'bar']!!
|
f3 := ['foo', 'bar']!
|
||||||
f4 := [u64(0xffffffffffffffff), 0xdeadface]!!
|
f4 := [u64(0xffffffffffffffff), 0xdeadface]!
|
||||||
|
|
||||||
println('
|
println('
|
||||||
$f1
|
$f1
|
||||||
|
@ -88,7 +88,7 @@ fn (mut p Parser) array_init() ast.ArrayInit {
|
|||||||
}
|
}
|
||||||
if p.tok.kind == .not && p.tok.line_nr == p.prev_tok.line_nr {
|
if p.tok.kind == .not && p.tok.line_nr == p.prev_tok.line_nr {
|
||||||
last_pos = p.tok.position()
|
last_pos = p.tok.position()
|
||||||
p.warn_with_pos('use e.g. `[1, 2, 3]!` instead of `[1, 2, 3]!!`', last_pos)
|
p.error_with_pos('use e.g. `[1, 2, 3]!` instead of `[1, 2, 3]!!`', last_pos)
|
||||||
p.next()
|
p.next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ fn test_conv_to_bool() {
|
|||||||
assert b
|
assert b
|
||||||
// check true -> 1
|
// check true -> 1
|
||||||
assert int(b) == 1
|
assert int(b) == 1
|
||||||
|
|
||||||
// branchless tests (can be important for manual optimization)
|
// branchless tests (can be important for manual optimization)
|
||||||
arr := [7,8]!!
|
arr := [7,8]!
|
||||||
e := arr[int(b)]
|
e := arr[int(b)]
|
||||||
assert e == 8
|
assert e == 8
|
||||||
b = e < 0
|
b = e < 0
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
fn test_fixed_array_lit_init() {
|
fn test_fixed_array_lit_init() {
|
||||||
a1 := ['1', '2', '3']!!
|
a1 := ['1', '2', '3']!
|
||||||
assert typeof(a1).name == '[3]string'
|
assert typeof(a1).name == '[3]string'
|
||||||
assert '$a1' == "['1', '2', '3']"
|
assert '$a1' == "['1', '2', '3']"
|
||||||
a2 := ['a', 'b']!!
|
a2 := ['a', 'b']!
|
||||||
assert typeof(a2).name == '[2]string'
|
assert typeof(a2).name == '[2]string'
|
||||||
assert '$a2' == "['a', 'b']"
|
assert '$a2' == "['a', 'b']"
|
||||||
c1 := [1, 2, 3]!!
|
c1 := [1, 2, 3]!
|
||||||
assert typeof(c1).name == '[3]int'
|
assert typeof(c1).name == '[3]int'
|
||||||
assert '$c1' == '[1, 2, 3]'
|
assert '$c1' == '[1, 2, 3]'
|
||||||
c2 := [i16(1), 2, 3]!!
|
c2 := [i16(1), 2, 3]!
|
||||||
assert typeof(c2).name == '[3]i16'
|
assert typeof(c2).name == '[3]i16'
|
||||||
assert '$c2' == '[1, 2, 3]'
|
assert '$c2' == '[1, 2, 3]'
|
||||||
mut c3 := [i64(1), 2, 3]!!
|
mut c3 := [i64(1), 2, 3]!
|
||||||
assert typeof(c3).name == '[3]i64'
|
assert typeof(c3).name == '[3]i64'
|
||||||
assert '$c3' == '[1, 2, 3]'
|
assert '$c3' == '[1, 2, 3]'
|
||||||
mut c4 := [u64(1), 2, 3]!!
|
mut c4 := [u64(1), 2, 3]!
|
||||||
assert typeof(c4).name == '[3]u64'
|
assert typeof(c4).name == '[3]u64'
|
||||||
assert '$c4' == '[1, 2, 3]'
|
assert '$c4' == '[1, 2, 3]'
|
||||||
mut d1 := [1.1, 2.2, 3.3]!!
|
mut d1 := [1.1, 2.2, 3.3]!
|
||||||
assert typeof(d1).name == '[3]f64'
|
assert typeof(d1).name == '[3]f64'
|
||||||
assert '$d1' == '[1.1, 2.2, 3.3]'
|
assert '$d1' == '[1.1, 2.2, 3.3]'
|
||||||
mut d2 := [f32(1.1), 2.2, 3.3]!!
|
mut d2 := [f32(1.1), 2.2, 3.3]!
|
||||||
assert typeof(d2).name == '[3]f32'
|
assert typeof(d2).name == '[3]f32'
|
||||||
assert '$d2' == '[1.1, 2.2, 3.3]'
|
assert '$d2' == '[1.1, 2.2, 3.3]'
|
||||||
}
|
}
|
||||||
@ -28,21 +28,21 @@ fn test_fixed_array_lit_init() {
|
|||||||
fn test_fixed_type_init() {
|
fn test_fixed_type_init() {
|
||||||
a := [2]int{}
|
a := [2]int{}
|
||||||
assert a == [2]int{}
|
assert a == [2]int{}
|
||||||
assert a == [0, 0]!!
|
assert a == [0, 0]!
|
||||||
assert a == a
|
assert a == a
|
||||||
mut c := [3, 3]!!
|
mut c := [3, 3]!
|
||||||
assert a != c
|
assert a != c
|
||||||
assert c == [3, 3]!!
|
assert c == [3, 3]!
|
||||||
c = [2]int{}
|
c = [2]int{}
|
||||||
assert a == c
|
assert a == c
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_fixed_custom_init() {
|
fn test_fixed_custom_init() {
|
||||||
a := [2]byte{init: 7}
|
a := [2]byte{init: 7}
|
||||||
assert a == [byte(7), 7]!!
|
assert a == [byte(7), 7]!
|
||||||
mut b := [3]int{}
|
mut b := [3]int{}
|
||||||
assert b == [0, 0, 0]!!
|
assert b == [0, 0, 0]!
|
||||||
// assign
|
// assign
|
||||||
b = [3]int{init: 5}
|
b = [3]int{init: 5}
|
||||||
assert b == [5, 5, 5]!!
|
assert b == [5, 5, 5]!
|
||||||
}
|
}
|
||||||
|
@ -86,56 +86,56 @@ fn test_map_of_bools() {
|
|||||||
|
|
||||||
fn test_fixed_array_of_floats() {
|
fn test_fixed_array_of_floats() {
|
||||||
// f64 array
|
// f64 array
|
||||||
aa := [1.2, 3.4, 5.67]!!
|
aa := [1.2, 3.4, 5.67]!
|
||||||
assert aa.str() == '[1.2, 3.4, 5.67]'
|
assert aa.str() == '[1.2, 3.4, 5.67]'
|
||||||
assert '$aa' == '[1.2, 3.4, 5.67]'
|
assert '$aa' == '[1.2, 3.4, 5.67]'
|
||||||
// f32 array
|
// f32 array
|
||||||
bb := [f32(1.2), 3.4, 5.67]!!
|
bb := [f32(1.2), 3.4, 5.67]!
|
||||||
assert bb.str() == '[1.2, 3.4, 5.67]'
|
assert bb.str() == '[1.2, 3.4, 5.67]'
|
||||||
assert '$bb' == '[1.2, 3.4, 5.67]'
|
assert '$bb' == '[1.2, 3.4, 5.67]'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_fixed_array_of_bools() {
|
fn test_fixed_array_of_bools() {
|
||||||
aa := [true, false, true]!!
|
aa := [true, false, true]!
|
||||||
assert aa.str() == '[true, false, true]'
|
assert aa.str() == '[true, false, true]'
|
||||||
assert '$aa' == '[true, false, true]'
|
assert '$aa' == '[true, false, true]'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_fixed_array_of_ints() {
|
fn test_fixed_array_of_ints() {
|
||||||
// int
|
// int
|
||||||
a1 := [11, 22, 33]!!
|
a1 := [11, 22, 33]!
|
||||||
assert a1.str() == '[11, 22, 33]'
|
assert a1.str() == '[11, 22, 33]'
|
||||||
assert '$a1' == '[11, 22, 33]'
|
assert '$a1' == '[11, 22, 33]'
|
||||||
// u32
|
// u32
|
||||||
a2 := [u32(11), 22, 33]!!
|
a2 := [u32(11), 22, 33]!
|
||||||
assert a2.str() == '[11, 22, 33]'
|
assert a2.str() == '[11, 22, 33]'
|
||||||
assert '$a2' == '[11, 22, 33]'
|
assert '$a2' == '[11, 22, 33]'
|
||||||
// i16
|
// i16
|
||||||
b1 := [i16(11), 22, 33]!!
|
b1 := [i16(11), 22, 33]!
|
||||||
assert b1.str() == '[11, 22, 33]'
|
assert b1.str() == '[11, 22, 33]'
|
||||||
assert '$b1' == '[11, 22, 33]'
|
assert '$b1' == '[11, 22, 33]'
|
||||||
// u16
|
// u16
|
||||||
b2 := [u16(11), 22, 33]!!
|
b2 := [u16(11), 22, 33]!
|
||||||
assert b2.str() == '[11, 22, 33]'
|
assert b2.str() == '[11, 22, 33]'
|
||||||
assert '$b2' == '[11, 22, 33]'
|
assert '$b2' == '[11, 22, 33]'
|
||||||
// i64
|
// i64
|
||||||
c1 := [i64(11), 22, 33]!!
|
c1 := [i64(11), 22, 33]!
|
||||||
assert c1.str() == '[11, 22, 33]'
|
assert c1.str() == '[11, 22, 33]'
|
||||||
assert '$c1' == '[11, 22, 33]'
|
assert '$c1' == '[11, 22, 33]'
|
||||||
// u64
|
// u64
|
||||||
c2 := [u64(11), 22, 33]!!
|
c2 := [u64(11), 22, 33]!
|
||||||
assert c2.str() == '[11, 22, 33]'
|
assert c2.str() == '[11, 22, 33]'
|
||||||
assert '$c2' == '[11, 22, 33]'
|
assert '$c2' == '[11, 22, 33]'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_fixed_array_of_runes() {
|
fn test_fixed_array_of_runes() {
|
||||||
aa := [`a`, `b`, `c`]!!
|
aa := [`a`, `b`, `c`]!
|
||||||
assert aa.str() == '[`a`, `b`, `c`]'
|
assert aa.str() == '[`a`, `b`, `c`]'
|
||||||
assert '$aa' == '[`a`, `b`, `c`]'
|
assert '$aa' == '[`a`, `b`, `c`]'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_fixed_array_of_strings() {
|
fn test_fixed_array_of_strings() {
|
||||||
aa := ['aa', 'bb', 'cc']!!
|
aa := ['aa', 'bb', 'cc']!
|
||||||
assert aa.str() == "['aa', 'bb', 'cc']"
|
assert aa.str() == "['aa', 'bb', 'cc']"
|
||||||
assert '$aa' == "['aa', 'bb', 'cc']"
|
assert '$aa' == "['aa', 'bb', 'cc']"
|
||||||
}
|
}
|
||||||
@ -243,7 +243,7 @@ fn test_alias_in_array() {
|
|||||||
|
|
||||||
type Alias2 = int
|
type Alias2 = int
|
||||||
fn test_alias_in_fixed_array() {
|
fn test_alias_in_fixed_array() {
|
||||||
t := [Alias1(1)]!!
|
t := [Alias1(1)]!
|
||||||
assert t.str() == '[1]'
|
assert t.str() == '[1]'
|
||||||
assert '$t' == '[1]'
|
assert '$t' == '[1]'
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ pub mut:
|
|||||||
fn test_fixed_array_struct_string_interpolation() {
|
fn test_fixed_array_struct_string_interpolation() {
|
||||||
mut ctx := Context{}
|
mut ctx := Context{}
|
||||||
x := 2.32
|
x := 2.32
|
||||||
ctx.vb = [1.1, x, 3.3, 4.4, 5.0, 6.0, 7.0, 8.9]!!
|
ctx.vb = [1.1, x, 3.3, 4.4, 5.0, 6.0, 7.0, 8.9]!
|
||||||
s := '$ctx'
|
s := '$ctx'
|
||||||
assert s.starts_with('Context{')
|
assert s.starts_with('Context{')
|
||||||
assert s.contains('vb: [1.1, 2.32, 3.3, 4.4, 5, 6, 7, 8.9]')
|
assert s.contains('vb: [1.1, 2.32, 3.3, 4.4, 5, 6, 7, 8.9]')
|
||||||
|
@ -14,8 +14,8 @@ fn memcpy(mut dest voidptr, src voidptr, len u32) voidptr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_mut_voidptr_arg() {
|
fn test_mut_voidptr_arg() {
|
||||||
mut a := [1, 2]!!
|
mut a := [1, 2]!
|
||||||
b := [3, 4]!!
|
b := [3, 4]!
|
||||||
memcpy(mut a, b, sizeof(int))
|
memcpy(mut a, b, sizeof(int))
|
||||||
assert a == [3, 2]!!
|
assert a == [3, 2]!
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ fn test_type_constructors() {
|
|||||||
v := `c`
|
v := `c`
|
||||||
assert typeof(&v).name == '&rune'
|
assert typeof(&v).name == '&rune'
|
||||||
assert typeof(&[v]).name == '&[]rune'
|
assert typeof(&[v]).name == '&[]rune'
|
||||||
assert typeof([v]!!).name == '[1]rune'
|
assert typeof([v]!).name == '[1]rune'
|
||||||
assert typeof(&[v]!!).name == '&[1]rune'
|
assert typeof(&[v]!).name == '&[1]rune'
|
||||||
assert typeof(&FooBar{}).name == '&FooBar'
|
assert typeof(&FooBar{}).name == '&FooBar'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ fn test_typeof_on_sumtypes() {
|
|||||||
assert typeof(a).name == 'MySumType'
|
assert typeof(a).name == 'MySumType'
|
||||||
assert typeof(b).name == 'MySumType'
|
assert typeof(b).name == 'MySumType'
|
||||||
assert typeof(c).name == 'MySumType'
|
assert typeof(c).name == 'MySumType'
|
||||||
|
|
||||||
assert a.str() == '32'
|
assert a.str() == '32'
|
||||||
assert b.str() == '123.'
|
assert b.str() == '123.'
|
||||||
assert c.str() == 'FooBar'
|
assert c.str() == 'FooBar'
|
||||||
@ -159,7 +159,7 @@ fn test_generic_type() {
|
|||||||
v := 5
|
v := 5
|
||||||
assert type_name(v) == 'int'
|
assert type_name(v) == 'int'
|
||||||
// assert type_name(&v) == '&int'
|
// assert type_name(&v) == '&int'
|
||||||
// assert type_name([v]!!) == '[1]int'
|
// assert type_name([v]!) == '[1]int'
|
||||||
assert type_name([v]) == '[]int'
|
assert type_name([v]) == '[]int'
|
||||||
assert type_name([[v]]) == '[][]int'
|
assert type_name([[v]]) == '[][]int'
|
||||||
assert type_name(FooBar{}) == 'FooBar'
|
assert type_name(FooBar{}) == 'FooBar'
|
||||||
|
Loading…
Reference in New Issue
Block a user