MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / test_cases

Function test_cases

utils/dasFormatter/main.cpp:35–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33};
34
35vector<TestData> test_cases() {
36 const string in_prefix = "[safe_when_uninitialized]\n"
37 "struct Foo\n"
38 " a : int = 5\n"
39 " b : float = 3.0\n"
40 "struct Bar\n"
41 " a : Foo\n"
42 "var var1 = ";
43 const string out_prefix = in_prefix;
44
45 const string postfix = "\n";
46 vector<TestData> base = {
47 {"[[/**/Foo/*0*/a/*a*/=/**/1/*a*///abc\n,//dsa\n/*dsa*/\nb=2.0/**/\n//dsa\n]]",
48 "/**/Foo(/*0*/a/*a*/=/**/1/*a*///abc\n,//dsa\n/*dsa*/\nb=2.0/**/\n//dsa\n)"}, // 1 // no uninit because it's redundant
49 {"[[/**/Foo/**/]]", "Foo(/**//**/)"}, // 2
50 {"[[/*a*/Foo(/*b*/)/*c*/]]", "Foo(/*a*//*b*//*c*/)"}, // 3
51 {"[[/*a*/Foo(/*b*/)/*c*/ a=1/*d*/,/*e*/b=2.0/*f*/]]", "/*a*//*b*/Foo(/*c*/ a=1/*d*/,/*e*/b=2.0/*f*/)"}, // 4
52 {"[[/*a*/auto/*b*/1/*c*/,/*d*/2/*e*/]]", "/*a*//*b*/(1/*c*/,/*d*/2/*e*/)"}, // 13
53// {"[[for x in [1, 20]; x*x; where x%2 == 0]];", "[iterator for x in [1, 20]; x*x; where x%2 == 0];"}, // 5 // each result is discarded, which is unsaf
54 {"[{/*a*/Foo/*b*/a=1/*c*/,/*d*/b=2./*e*/;/*f*/a=2/*g*/,/*h*/b=1./*i*/}]",
55 "[/*a*/Foo(/*b*/a=1/*c*/,/*d*/b=2./*e*/), Foo(/*f*/a=2/*g*/,/*h*/b=1./*i*/)]"}, // 6
56 {"[{/*a*/Foo()/*b*/a=1/*c*/,/*d*/b=2./*e*/;/*g*/a=2/*h*/,/*i*/b=1./*j*/}]",
57 "[/*a*/Foo(/*b*/a=1/*c*/,/*d*/b=2./*e*/), Foo(/*g*/a=2/*h*/,/*i*/b=1./*j*/)]"}, // 7
58// {"[{Foo a=1,b=2.;a=2,b=1. <optional_block>}]", "[Foo(a=1,b=2.),Foo(a=2,b=1.)]"}, // what about optional block in new syntax
59 {"[{/*a*/auto/*b*/1/*c*/;/*d*/2/*e*/;/*f*/3/*g*/;/*h*/4/*i*/}]",
60 "[/*a*//*b*/1/*c*/,/*d*/2/*e*/,/*f*/3/*g*/,/*h*/4/*i*/]"}, // 8
61 {"[{/*a*/auto/*b*/1/*c*/,/*d*/2.2/*e*/}]", "[/*a*//*b*/(1/*c*/,/*d*/2.2/*e*/)]"}, // 8
62 {"[{/*a*/for/*b*/x/*c*/in/*d*/0..10/*e*/;/*f*/x*x/*g*/;/*h*/where/*i*/x%2==0/*j*/}]",
63 "[/*a*/for/*b*/x/*c*/in/*d*/0..10/*e*/;/*f*/x*x/*g*/;/*h*/where/*i*/x%2==0/*j*/]"}, // 9
64 {"{{/*a*/for/*b*/x/*c*/in/*d*/0..10/*e*/;/*f*/x*x/*g*/;/*h*/where/*i*/x%2==0/*j*/}}",
65 "[/*a*/for/*b*/x/*c*/in/*d*/0..10/*e*/;/*f*/x*x/*g*/;/*h*/where/*i*/x%2==0/*j*/]"}, // 12
66 {"{{/*a*/1/*b*/;/*c*/2/*d*/;/*e*/3/*f*/;/*g*/4/*h*/}}", "{/*a*/1/*b*/,/*c*/2/*d*/,/*e*/3/*f*/,/*g*/4/*h*/}"}, // 10
67 {R"({{/*a*/1=>"a"/*b*/;/*c*/2=>"b"/*d*/;/*e*/3=>"c"/*f*/;/*g*/4=>"d"/*h*/}})",
68 R"({/*a*/1=>"a"/*b*/,/*c*/2=>"b"/*d*/,/*e*/3=>"c"/*f*/,/*g*/4=>"d"/*h*/})"}, // 10
69 {R"([[/*a*/auto/*b*/1/*c*/,/*d*/2./*e*/,/*f*/"3"/*g*/;/*h*/1/*i*/,/*j*/4./*k*/,/*l*/"2"/*m*/]])",
70 R"(fixed_array(/*a*//*b*/(1/*c*/,/*d*/2./*e*/,/*f*/"3"/*g*/),/*h*/(1/*i*/,/*j*/4./*k*/,/*l*/"2"/*m*/)))"}, // 13
71//
72// // anything
73 {"[[/*a*/auto/*b*/1/*c*/;/*d*/2/*e*/]]",
74 "fixed_array(/*a*//*b*/1/*c*/,/*d*/2/*e*/)"},
75 {"[[/*a*/Foo?/*b*/]]", "default<Foo?>/*a*//*b*/"},
76 {"[[/*a*/Foo#/*b*/]]", "struct<Foo#>(/*a*//*b*/)"},
77 {"[[tuple<string; float>\n"
78 " \"a\", 1.0;\n"
79 " \"b\", 2.0;"
80 "]]",
81 "fixed_array<tuple<string; float>>(\n"
82 " (\"a\", 1.0),\n"
83 " (\"b\", 2.0))"},
84 {
85 "[[auto[] \"a\" ]]\n",
86 "fixed_array( \"a\" )\n",
87 },
88
89
90 // nested
91
92 {"[[/*a*/Bar/*b*/a=[[/*c*/Foo/*f*/b=2.0/*g*/]]/*h*/]]",

Callers 1

testFunction · 0.85

Calls 4

FormatOptionsClass · 0.85
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected