From 33bd22eda9eb7c3ad43e74d721328b9ae1b1cee7 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 7 Mar 2021 18:47:58 +0200 Subject: [PATCH] vlib/v/gen/tests: remove obsolete generation tests (used during the AST migration from v1 to v2) --- vlib/v/gen/c/cgen_test.v | 70 ------- vlib/v/gen/tests/1.c | 277 --------------------------- vlib/v/gen/tests/1.vv | 274 -------------------------- vlib/v/gen/tests/2.c | 86 --------- vlib/v/gen/tests/2.vv | 83 -------- vlib/v/gen/tests/3.c | 99 ---------- vlib/v/gen/tests/3.vv | 70 ------- vlib/v/gen/tests/4.c | 136 ------------- vlib/v/gen/tests/4.vv | 102 ---------- vlib/v/gen/tests/if_expr.vv | 5 - vlib/v/gen/tests/localmod/localmod.v | 13 -- 11 files changed, 1215 deletions(-) delete mode 100644 vlib/v/gen/c/cgen_test.v delete mode 100644 vlib/v/gen/tests/1.c delete mode 100644 vlib/v/gen/tests/1.vv delete mode 100644 vlib/v/gen/tests/2.c delete mode 100644 vlib/v/gen/tests/2.vv delete mode 100644 vlib/v/gen/tests/3.c delete mode 100644 vlib/v/gen/tests/3.vv delete mode 100644 vlib/v/gen/tests/4.c delete mode 100644 vlib/v/gen/tests/4.vv delete mode 100644 vlib/v/gen/tests/if_expr.vv delete mode 100644 vlib/v/gen/tests/localmod/localmod.v diff --git a/vlib/v/gen/c/cgen_test.v b/vlib/v/gen/c/cgen_test.v deleted file mode 100644 index 1aa5b5de50..0000000000 --- a/vlib/v/gen/c/cgen_test.v +++ /dev/null @@ -1,70 +0,0 @@ -import os -import v.pref -import v.builder -import term - -const ( - nr_tests = 4 - term_ok = term.ok_message('OK') - term_fail = term.fail_message('FAIL') -) - -fn test_c_files() { - if true { - return - } - println('Running V => C tests') - vexe := os.getenv('VEXE') - vroot := os.dir(vexe) - for i in 1 .. (nr_tests + 1) { - path := '$vroot/vlib/v/gen/tests/${i}.vv' - ctext := os.read_file('$vroot/vlib/v/gen/tests/${i}.c') or { panic(err) } - mut b := builder.new_builder(&pref.Preferences{}) - b.module_search_paths = ['$vroot/vlib/v/gen/tests/'] - mut res := b.gen_c([path]).after('#endbuiltin') - if res.contains('string _STR') { - pos := res.index('string _STR') or { -1 } - end := res.index_after('endof _STR_TMP', pos) - res = res[..pos] + res[end + 15..] - } - if compare_texts(res, ctext, path) { - println('$term_ok $i') - } else { - assert false - } - } -} - -fn compare_texts(a string, b string, path string) bool { - lines_a_ := a.trim_space().split_into_lines() - lines_b_ := b.trim_space().split_into_lines() - lines_a := lines_a_.filter(it != '') - mut lines_b := lines_b_.filter(it != '') - lines_b << '' - lines_b << '' - /* - if lines_a.len != lines_b.len { - println(term.red('different len')) - println('${path}: got\n$a') - return false - } - */ - for i, line_a in lines_a { - if i >= lines_b.len { - println(line_a) - return false - } - line_b := lines_b[i] - if line_a.trim_space() != line_b.trim_space() { - println('$path: Got\n$a') - println('$path:$i: $term_fail') - println(term.bold(term.bright_yellow('actual : ')) + line_a) - println(term.green('expected: ') + line_b) - println(lines_b[i + 1]) - println(lines_b[i + 2]) - // exit(1) - return false - } - } - return true -} diff --git a/vlib/v/gen/tests/1.c b/vlib/v/gen/tests/1.c deleted file mode 100644 index d1b36b1f63..0000000000 --- a/vlib/v/gen/tests/1.c +++ /dev/null @@ -1,277 +0,0 @@ -typedef enum { - Color_red, // 0 - Color_green, // 1 - Color_blue, // 2 -} Color; - -struct Two { -}; - -struct User { - int age; - string name; -}; - -struct One { - Two two; -}; - -// multi return structs -typedef struct { - int arg0; - string arg1; -} multi_return_int_string; -// end of definitions #endif -#define _const_pi 3 -int _const_pi2; // inited later -string int_str(int* x) { return tos3("TODO_str"); } -void foo(int a); -void User_inc_age(User* u, int n); -int get_int(string a); -bool get_bool(); -int get_int2(); -void myuser(); -multi_return_int_string multi_return(); -void variadic(varg_int a); -void ensure_cap(int required, int cap); -void println(string s); -void matches(); -#define _const_path_sep 10 -void end(); -int function1(); -void foo(int a); -void init_user(); -User get_user(); -void puts(string s); -void function2(); -void init_array(); -#define _const_localmod__pub_int_const 20 -void localmod__pub_foo(); -int localmod__get_int_10(); -// variadic structs -struct varg_int { - int len; - int args[0]; -}; - -// >> typeof() support for sum types -// << typeof() support for sum types - -// -int main(int argc, char** argv) { - _vinit(); - int a = 10; - a++; - int negative = -a; - 2 < 3; - a == 1; - a++; - foo(3); - int ak = 10; - int mypi = _const_pi; - Color color = Color_red; - localmod__pub_foo(); - int ten = localmod__get_int_10(); - println(int_str(_const_localmod__pub_int_const)); - int g = ((int)(3.0)); - byte* bytes = ((byte*)(0)); - User* user_ptr = (User*)memdup(&(User){ .age = 0, - .name = tos3(""), -}, sizeof(User)); - return 0; -} - -void foo(int a) { - while (true) { - } - for (int i = 0; -i < 10; i++) { - } - array_int nums = new_array_from_c_array(3, 3, sizeof(int), (int[3]){ - 1, 2, 3, - }); - array_int nums2 = array_slice(nums, 0, 2); - array_int nums3 = array_slice(nums, 1, 2); - array_int nums4 = array_slice(nums, 1, nums.len); - int number = (*(int*)array_get(nums, 0)); - array_set(&nums, 1, &(int[]) { 10 }); - array_bool bools = new_array_from_c_array(2, 2, sizeof(bool), (bool[2]){ - true, false, - }); - array_User users = new_array_from_c_array(1, 1, sizeof(User), (User[1]){ - (User){ - .age = 0, - .name = tos3(""), - }, - }); - bool b = (*(bool*)array_get(bools, 0)); - array_string mystrings = new_array_from_c_array(2, 2, sizeof(string), (string[2]){ - tos3("a"), tos3("b"), - }); - string s = (*(string*)array_get(mystrings, 0)); - int x = 0; - x = get_int2(); - int n = get_int2(); - bool q = true || false; - bool b2 = (*(bool*)array_get(bools, 0)) || true; - bool b3 = get_bool() || true; - int f = *(int*)array_first(nums); - array_int c = array_clone(&nums); - string d = tos3("d"); - println(string_add(s, d)); -} - -void User_inc_age(User* u, int n) { - printf("%d", u->age); - u->age += n; -} - -int get_int(string a) { - return 10; -} - -bool get_bool() { - return true; -} - -int get_int2() { - string a = tos3("hello"); - return get_int(a); -} - -void myuser() { - int x = 1; - int q = x | 0x1004; - User user = (User){ - .age = 30, - .name = tos3(""), - }; - int age = user.age + 1; - int boo = 2; - int boo2 = boo + 1; - bool b = age > 0; - bool b2 = user.age > 0; - User user2 = (User){ - .age = 20, - .name = tos3(""), - }; - user2.age = 20 + boo; -} - -multi_return_int_string multi_return() { - return (multi_return_int_string){.arg0=4,.arg1=tos3("four")}; -} - -void variadic(varg_int a) { - int x = _const_path_sep; - int y = (true ? 1 : 0); -} - -void ensure_cap(int required, int cap) { - if (required < cap) { - return; - } -} - -void println(string s) { -} - -void matches() { - int a = 100; - if (a == 10) { - println(tos3("10")); - } - else if (a == 20) { - int k = a + 1; - } - else { - } - ; - string x = (a == 10) ? tos3("ten") : (a == 30) ? tos3("thirty") : tos3("unknown"); - int xx = (a == 10) ? 100 : (a == 30) ? 300 : 0; - println((a == 10) ? tos3("ten") : tos3("not ten")); -} - -void end() { - int i = 2; - int key = 10; - bool x = i != -1 && key == 10; - int e = 2 + 3 * 4; -} - -int function1() { - int a = 10 + 1; - int b = a + 1; - return 0; -} - - -void foo(int a) { -} - -void init_user() { - User user = (User){ - .name = tos3("Bob"), - .age = 0, - }; -} - -User get_user() { - User user = (User){ - .age = 0, - .name = tos3(""), - }; - return user; -} - -void puts(string s) { -} - -void function2() { - int x = 0; - f64 f = 10.1; - string s = tos3("hi"); - int m = 10; - x += 10; - x += 1; - m += 2; - function1(); - if (true) { - foo(10); - x += 8; - } - if (false) { - foo(1); - } else { - puts(tos3("else")); - foo(100); - } - while (true) { - init_user(); - } - bool e = 1 + 2 > 0; - bool e2 = 1 + 2 < 0; - int j = 0; -} - -void init_array() { - array_int nums = new_array_from_c_array(3, 3, sizeof(int), (int[3]){ - 4, 2, 3, - }); -} - -void localmod__pub_foo() { - int a = 10; -} - -int localmod__get_int_10() { - return 10; -} - - -void _vinit() { - _const_pi2 = _const_pi; -} - - - diff --git a/vlib/v/gen/tests/1.vv b/vlib/v/gen/tests/1.vv deleted file mode 100644 index 9cf3370f0f..0000000000 --- a/vlib/v/gen/tests/1.vv +++ /dev/null @@ -1,274 +0,0 @@ -//import moda -//import modb as mb - -import localmod - -const ( - pi = 3 - pi2 = pi - //s = 'hi' - -) - -struct User { - age int - name string -} - -enum Color { - red green blue -} - -fn main() { - a := 10 - //bb := 2 + 'hi' - a++ - negative := -a - 2 < 3 - a == 1 - a++ - foo(3) - ak := 10 - mypi := pi - color := Color.red - localmod.pub_foo() - ten := localmod.get_int_10() - println(localmod.pub_int_const) - g := int(3.0) - bytes := &byte(0) - user_ptr := &User{} -} - /* - user := User{} - user.age = 10 - mut x := if user.age == 10 { 20 } else { user.age * 2 } - for x > 3 { - - } - */ - -struct One { - two Two -} - -struct Two { - -} - -fn foo(a int) { - for true { - - } - for i := 0; i < 10; i++ { - - } - mut nums := [1,2,3] - nums2 := nums[..2] - nums3 := nums[1..2] - nums4 := nums[1..] - number := nums[0] - nums[1] = 10 - bools := [true, false] - users := [User{}] - //ptr := &User{} - b := bools[0] - mystrings := ['a', 'b'] - s := mystrings[0] - ////////// - mut x := 0 - x=get_int2() - n := get_int2() - q := true || false - b2 := bools[0] || true - b3 := get_bool() || true - f := nums.first() - c := nums.clone() - d := 'd' - println(s + d) - //cloned = nums.clone() - //cloned1 := cloned[0] - //println(cloned1 == 1) - /* - mut strings := ['hi', 'hello'] - strings << 'a' + b - */ - -} - -fn C.printf() - -fn (u mut User) inc_age(n int) { - C.printf("%d", u.age) - u.age += n -} - -fn get_int(a string) int { - return 10 -} - -fn get_bool() bool { - return true -} - -fn get_int2() int { - a := 'hello' - //return get_int('sdf') - return get_int(a) -} - -fn myuser() { - x := 1 - q := x | 0x1004 - user := User{age:30} - age := user.age + 1 // crash here - boo := 2 - boo2 := boo+1 - b := age > 0 - b2 := user.age > 0 - mut user2 := User{age:20} - user2.age = 20 + boo -} - -fn multi_return() (int,string) { - return 4, 'four' -} - -fn variadic(a ...int) { - x := path_sep - y := if true { 1 } else { 0 } // TODO cgen -} - -fn ensure_cap(required int, cap int) { - if required < cap { - return - } -} - -fn println(s string){} - -fn matches() { - a := 100 - match a { - 10 { - println('10') - } - 20 { - k := a + 1 - } - else{} - } - x := match a { - 10 { 'ten' } - 30 { 'thirty' } - else { 'unknown' } - } - xx := match a { - 10 { 100 } - 30 { 300 } - else { 0 } - } - println(match a { 10 { 'ten' } else { 'not ten' } }) - /* - n := match a { - 1 { 10 } - 2 { 20 } - else { 30 } - } - */ -} - -const ( - path_sep = 10 -) - -fn end() { - i := 2 - key := 10 - x := i != -1 && key == 10 // key == keys[i] - e := 2 + 3 * 4 - //mut a := [1,2,3] - //(a << 4) + 2 -} - -/////////////////////////////////////////////////////////// - -fn function1() int { - a := 10 + 1 - b := a + 1 - //return a - return 0 -} - -fn foo(a int) { - //end() -} - -struct User { - name string -} - -fn init_user() { - user := User{ - name: 'Bob' - } -} - -fn get_user() User { - user := User{} - return user -} - - -fn puts(s string) {} - -// comment -fn function2() { - mut x := 0 - //mut negative := -1 - f := 10.1 - s := 'hi' - mut m := 10 - x += 10 - x += 1 - m += 2 - function1() - // a += 1 - // c := 0 - if true { - foo(10) - x += 8 - } - if false { - foo(1) - } - else { - puts('else') - foo(100) - } - for true { - init_user() - } - e := 1 + 2 > 0 - e2 := 1 + 2 < 0 - // x += 1 - j := 0 -} - -fn init_array() { - nums := [4,2,3] - -} - - -/* -fn bool_array() { - a := [true, false] - b := a[0] - if b { - println('ok') - } -} -*/ - - - diff --git a/vlib/v/gen/tests/2.c b/vlib/v/gen/tests/2.c deleted file mode 100644 index bebf4b8ffd..0000000000 --- a/vlib/v/gen/tests/2.c +++ /dev/null @@ -1,86 +0,0 @@ -struct User { - string name; -}; - -// multi return structs -// end of definitions #endif -int function1(); -void foo(int a); -void init_user(); -User get_user(); -void puts(string s); -void function2(); -void init_array(); -void end(); -// >> typeof() support for sum types -// << typeof() support for sum types - -int function1() { - int a = 10 + 1; - int b = a + 1; - return 0; -} - -void foo(int a) { -} - -void init_user() { - User user = (User){ - .name = tos3("Bob"), - }; -} - -User get_user() { - User user = (User){ - .name = tos3(""), - }; - return user; -} - -void puts(string s) { -} - -void function2() { - int x = 0; - f64 f = 10.1; - string s = tos3("hi"); - int m = 10; - x += 10; - x += 1; - m += 2; - function1(); - if (true) { - foo(10); - x += 8; - } - if (false) { - foo(1); - } else { - puts(tos3("else")); - foo(100); - } - while (true) { - init_user(); - } - bool e = 1 + 2 > 0; - bool e2 = 1 + 2 < 0; - int j = 0; -} - -void init_array() { - array_int nums = new_array_from_c_array(3, 3, sizeof(int), (int[3]){ - 4, 2, 3, - }); -} - -void end() { -} - -int main(int argc, char** argv) { - _vinit(); - return 0; -} - -void _vinit() { - -} diff --git a/vlib/v/gen/tests/2.vv b/vlib/v/gen/tests/2.vv deleted file mode 100644 index e0dee60fe9..0000000000 --- a/vlib/v/gen/tests/2.vv +++ /dev/null @@ -1,83 +0,0 @@ -fn function1() int { - a := 10 + 1 - b := a + 1 - //return a - return 0 -} - -fn foo(a int) { - //end() -} - -struct User { - name string -} - -fn init_user() { - user := User{ - name: 'Bob' - } -} - -fn get_user() User { - user := User{} - return user -} - - -fn puts(s string) {} - -// comment -fn function2() { - mut x := 0 - //mut negative := -1 - f := 10.1 - s := 'hi' - mut m := 10 - x += 10 - x += 1 - m += 2 - function1() - // a += 1 - // c := 0 - if true { - foo(10) - x += 8 - } - if false { - foo(1) - } - else { - puts('else') - foo(100) - } - for true { - init_user() - } - e := 1 + 2 > 0 - e2 := 1 + 2 < 0 - // x += 1 - j := 0 -} - -fn init_array() { - nums := [4,2,3] - -} - -fn end() { - -} - -/* -fn bool_array() { - a := [true, false] - b := a[0] - if b { - println('ok') - } -} -*/ - -fn main() { - } diff --git a/vlib/v/gen/tests/3.c b/vlib/v/gen/tests/3.c deleted file mode 100644 index 00116bf186..0000000000 --- a/vlib/v/gen/tests/3.c +++ /dev/null @@ -1,99 +0,0 @@ -struct IfExpr { -}; - -struct IntegerLiteral { -}; - -// Sum type -typedef struct { - void* obj; - int typ; -} Expr; - -struct User { - int age; - string name; -}; - -// multi return structs -// end of definitions #endif -typedef Option Option_int; -Option_int get_opt(); -void User_foo(User* u); -void println(string s); -void handle_expr(Expr e); -// >> typeof() support for sum types -char * v_typeof_sumtype_28(int sidx) { /* Expr */ - switch(sidx) { - case 28: return "Expr"; - case 26: return "IfExpr"; - case 27: return "IntegerLiteral"; - default: return "unknown Expr"; - } -} -// << typeof() support for sum types - -// TypeDecl - -Option_int get_opt() { - return opt_ok(& (int []) { 0 }, sizeof(int)); -} - -void User_foo(User* u) { - int age = u->age; - array_string zzz = array_repeat(new_array_from_c_array(1, 1, sizeof(string), (string[1]){ -tos3(""), -}), u->age); - int a = 10; - if ((a == 10 || a == 20 || a == 30)) { - int b = 10; - } - string name = tos3("Bob"); - println(tos3("hello")); - println(_STR("Hello, %.*s", name.len, name.str)); - println(_STR("age = %d", age)); - println(_STR("name=%.*s age=%d", name.len, name.str, age)); -} - -void println(string s) { -} - -void handle_expr(Expr e) { - if (e.typ == 26 /* IfExpr */) { - IfExpr* it = (IfExpr*)e.obj; // ST it - println(tos3("if")); - } - else if (e.typ == 27 /* IntegerLiteral */) { - IntegerLiteral* it = (IntegerLiteral*)e.obj; // ST it - println(tos3("integer")); - } - else { - println(tos3("else")); - } - ; -} - -int main(int argc, char** argv) { - _vinit(); - User user = (User){ - .age = 0, - .name = tos3(""), - }; - user.age = 10; - user.age++; - user.name = tos3("bob"); - Option_int n = get_opt(); - if (!n.ok) { - string err = n.v_error; - int errcode = n.ecode; - return 0; - }; - int a = /*opt*/(*(int*)n.data) + 3; - handle_expr(/* sum type cast */ (Expr) {.obj = memdup(&(IfExpr[]) {(IfExpr){ -0}}, sizeof(IfExpr)), .typ = 26 /* IfExpr */}); - return 0; -} - -void _vinit() { - -} diff --git a/vlib/v/gen/tests/3.vv b/vlib/v/gen/tests/3.vv deleted file mode 100644 index 15c2bf1a98..0000000000 --- a/vlib/v/gen/tests/3.vv +++ /dev/null @@ -1,70 +0,0 @@ -type Expr = IfExpr | IntegerLiteral - -struct IfExpr{} -struct IntegerLiteral{} - -struct User { - age int - name string -} - -fn get_opt() ?int { - return 0 -} - -/* -fn new_user() User { - return User{} -} - -fn get_user_opt() ?User { - return new_user() - //return User{age:20, name:'Peter'} -} -*/ - -fn (u &User) foo() { - age := u.age - zzz := []string{len:(u.age)} - a := 10 - if a in [10, 20, 30] { - b := 10 - } - name := 'Bob' - println('hello') - println('Hello, $name') - println('age = $age') - println('name=$name age=$age') -} - -fn println(s string) {} - -fn handle_expr(e Expr) { - match e { - IfExpr { - println('if') - - - } - IntegerLiteral { - println('integer') - - } - else { - println('else') - } - } - -} - -fn main() { - user := User{} - user.age = 10 - user.age++ - user.name = 'bob' - n := get_opt() or { - return - } - a := n + 3 - handle_expr(IfExpr{}) -} diff --git a/vlib/v/gen/tests/4.c b/vlib/v/gen/tests/4.c deleted file mode 100644 index 6f86fe4b77..0000000000 --- a/vlib/v/gen/tests/4.c +++ /dev/null @@ -1,136 +0,0 @@ -struct Bar { - int a; -}; - -struct Foo { - string a; - Bar b; -}; - -// multi return structs -typedef struct { - int arg0; - string arg1; -} multi_return_int_string; - -// end of definitions #endif -typedef Option Option_string; -typedef Option Option_multi_return_int_string; -multi_return_int_string mr_test(); -int testa(); -string testb(int a); -int testc(int a); -int Foo_testa(Foo* f); -int Foo_testb(Foo* f); -int Bar_testa(Bar* b); -Option_string optional_a(); -Option_string optional_b(); -Option_multi_return_int_string optional_mr(); -// >> typeof() support for sum types -// << typeof() support for sum types - -int main(int argc, char** argv) { - _vinit(); - Bar b = (Bar){ - .a = 122, - }; - Foo a = (Foo){ - .a = tos3("hello"), - .b = b, - }; - a.a = tos3("da"); - a.b.a = 111; - string a1 = a.a; - int a2 = Bar_testa(&b); - int c = testa(); - c = 1; - string d = testb(1); - d = tos3("hello"); - string e = tos3("hello"); - e = testb(111); - e = tos3("world"); - array_int f = new_array_from_c_array(4, 4, sizeof(int), (int[4]){ - testa(), 2, 3, 4, - }); - array_string g = new_array_from_c_array(2, 2, sizeof(string), (string[2]){ - testb(1), tos3("hello"), - }); - array_Foo arr_foo = new_array_from_c_array(1, 1, sizeof(Foo), (Foo[1]){ - a, - }); - Foo af_idx_el = (*(Foo*)array_get(arr_foo, 0)); - string foo_a = af_idx_el.a; - map_string_string m1 = new_map(sizeof(string)); - map_string_int m2 = new_map_init(2, sizeof(int), (string[2]){tos3("v"), tos3("lang"), }, (int[2]){1, 2, }); - string ma1 = tos3("hello"); - string ma2 = tos3("vlang"); - multi_return_int_string mr_566 = mr_test(); - int mr1 = mr_566.arg0; - string mr2 = mr_566.arg1; - string opt1 = tos3("opt1"); - Option_string opt2 = optional_a(); - if (!opt2.ok) { - string err = opt2.v_error; - int errcode = opt2.ecode; - }; - string opt3 = tos3("opt3"); - Option_string opt4 = optional_b(); - if (!opt4.ok) { - string err = opt4.v_error; - int errcode = opt4.ecode; - }; - Option_multi_return_int_string mr_669 = optional_mr(); - if (!mr_669.ok) { - string err = mr_669.v_error; - int errcode = mr_669.ecode; - }; - int opt_mr1 = (*(multi_return_int_string*)mr_669.data).arg0; - string opt_mr12 = (*(multi_return_int_string*)mr_669.data).arg1; - return 0; -} - -multi_return_int_string mr_test() { - return (multi_return_int_string){.arg0=1,.arg1=tos3("v")}; -} - -int testa() { - return testc(1); -} - -string testb(int a) { - return tos3("hello"); -} - -int testc(int a) { - return a; -} - -int Foo_testa(Foo* f) { - int a = Foo_testb(f); - a = 1; - return 4; -} - -int Foo_testb(Foo* f) { - return 4; -} - -int Bar_testa(Bar* b) { - return 4; -} - -Option_string optional_a() { - return opt_ok(& (string []) { tos3("111") }, sizeof(string)); -} - -Option_string optional_b() { - return opt_ok(& (string []) { tos3("222") }, sizeof(string)); -} - -Option_multi_return_int_string optional_mr() { - return opt_ok(& (multi_return_int_string []) { (multi_return_int_string){.arg0=1,.arg1=tos3("111")} }, sizeof(multi_return_int_string)); -} - -void _vinit() { - -} diff --git a/vlib/v/gen/tests/4.vv b/vlib/v/gen/tests/4.vv deleted file mode 100644 index 26031b83b8..0000000000 --- a/vlib/v/gen/tests/4.vv +++ /dev/null @@ -1,102 +0,0 @@ -module main - -// import moda - -// import ( -// modb -// modc -// ) - -fn main() { - b := Bar{a: 122} - mut a := Foo{ - a: 'hello' - b: b - } - a.a = 'da' - a.b.a = 111 - - a1 := a.a - a2 := b.testa() - - mut c := testa() - c = 1 - mut d := testb(1) - d = 'hello' - - mut e := 'hello' - e = testb(111) - e = 'world' - - mut f := [testa(),2,3,4] - mut g := [testb(1),'hello'] - - //mut arr_foo := []Foo - arr_foo := [a] - //arr_foo << a // TODO - af_idx_el := arr_foo[0] - foo_a := af_idx_el.a - - mut m1 := map[string]string - mut m2 := {'v': 1, 'lang': 2} - - ma1, ma2 := 'hello', 'vlang' - mr1, mr2 := mr_test() - - opt1, opt2, opt3, opt4 := 'opt1', optional_a(), 'opt3', optional_b() - opt_mr1, opt_mr12 := optional_mr() or { - // err - } -} - -fn mr_test() (int, string) { - return 1,'v' -} - -fn testa() int { - return testc(1) -} - -fn testb(a int) string { - return 'hello' -} - -fn testc(a int) int { - return a -} - -fn (f &Foo) testa() int { - mut a := f.testb() - a = 1 - return 4 -} - -fn (f &Foo) testb() int { - return 4 -} - -fn (b &Bar) testa() int { - return 4 -} - -struct Bar { - a int -} - -struct Foo{ - a string - b Bar -} - -fn optional_a() ?string { - return '111' -} - -fn optional_b() ?string { - return '222' -} - -fn optional_mr() ?(int, string) { - return 1, '111' -} - diff --git a/vlib/v/gen/tests/if_expr.vv b/vlib/v/gen/tests/if_expr.vv deleted file mode 100644 index f5ba3856e7..0000000000 --- a/vlib/v/gen/tests/if_expr.vv +++ /dev/null @@ -1,5 +0,0 @@ -fn foo() { - a := if true { 1 } else { 2 } - - -} diff --git a/vlib/v/gen/tests/localmod/localmod.v b/vlib/v/gen/tests/localmod/localmod.v deleted file mode 100644 index 6ef2e1ae33..0000000000 --- a/vlib/v/gen/tests/localmod/localmod.v +++ /dev/null @@ -1,13 +0,0 @@ -module localmod - -pub const ( - pub_int_const = 20 -) - -pub fn pub_foo() { - a := 10 -} - -pub fn get_int_10() int { - return 10 -}