io: remove unused Zzz_CoerceInterfaceTableGeneration struct; add test for `x := Enum{}`

pull/8796/head
Delyan Angelov 2021-02-17 01:37:05 +02:00
parent 995e1c84a2
commit 2002d20249
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 19 additions and 22 deletions

View File

@ -4,7 +4,7 @@ module io
pub interface ReaderWriter { pub interface ReaderWriter {
// from Reader // from Reader
read(mut buf []byte) ?int read(mut buf []byte) ?int
// from Writer // from Writer
write(buf []byte) ?int write(buf []byte) ?int
} }
@ -31,19 +31,3 @@ pub fn make_readerwriter(r Reader, w Writer) ReaderWriterImpl {
w: w w: w
} }
} }
struct Zzz_CoerceInterfaceTableGeneration {
}
fn (_ Zzz_CoerceInterfaceTableGeneration) write(buf []byte) ?int {
return none
}
fn (_ Zzz_CoerceInterfaceTableGeneration) read(mut buf []byte) ?int {
return none
}
fn zzz_reader_writer_coerce_compiler() {
x := Zzz_CoerceInterfaceTableGeneration{}
_ := make_readerwriter(x, x)
}

View File

@ -5037,10 +5037,8 @@ fn (mut g Gen) struct_init(struct_init ast.StructInit) {
g.indent-- g.indent--
} }
if g.pref.ccompiler == 'msvc' { if !initialized {
if !initialized { g.write('\n#ifndef __cplusplus\n0\n#endif\n')
g.write('\n#ifndef __cplusplus\n0\n#endif\n')
}
} }
g.write('}') g.write('}')

View File

@ -34,7 +34,7 @@ fn test_enum() {
fn test_in() { fn test_in() {
color := Color.red color := Color.red
num := 3 // used to be an expr bug before `in` num := 3 // used to be an expr bug before `in`
assert color in [.red, .green] assert color in [.red, .green]
assert num == 3 assert num == 3
println(color) println(color)
@ -118,3 +118,18 @@ fn test_typed_enum() {
} }
} }
*/ */
enum FileType {
unknown
wiki
file
image
html
}
fn test_enum_instance() {
mut filetype := FileType{}
eprintln(filetype)
s := 'x $filetype z'
assert s == 'x unknown z'
}