Skip to content

Commit cfb0d0d

Browse files
committed
简单测试
1 parent a86a99d commit cfb0d0d

File tree

5 files changed

+239
-3
lines changed

5 files changed

+239
-3
lines changed

Test/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ target_sources(CodeFormatTest
1818

1919
target_link_libraries(CodeFormatTest CodeService Util)
2020

21-
add_test(NAME CodeFormatTest COMMAND CodeFormatTest CheckGrammar -w ${CodeFormatTest_SOURCE_DIR}/test_script/grammar)
21+
add_test(NAME GrammarTest COMMAND CodeFormatTest CheckGrammar -w ${CodeFormatTest_SOURCE_DIR}/test_script/grammar)
22+
add_test(NAME FormatTest COMMAND CodeFormatTest CheckFormat -w ${CodeFormatTest_SOURCE_DIR}/test_script/format_text -f ${CodeFormatTest_SOURCE_DIR}/test_script/format_text_shouldbe)

Test/src/CodeFormatTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ int main(int argc, char* argv[])
119119
bool passed = TestFormatted(waitFormattingText, formattedText, options);
120120

121121
success &= passed;
122-
std::cout << format("test format {} ... {}", path, passed ? "true" : "false") << std::endl;
122+
std::cout << format("test format {} ... {}", path, passed ? "passed" : "false") << std::endl;
123123
}
124124
}
125125
else if (target == "CheckGrammar")
@@ -132,7 +132,7 @@ int main(int argc, char* argv[])
132132
bool passed = TestGrammar(text);
133133

134134
success &= passed;
135-
std::cout << format("test check grammar {} ... {}", path, passed? "true" : "false") << std::endl;
135+
std::cout << format("test check grammar {} ... {}", path, passed? "passed" : "false") << std::endl;
136136
}
137137
}
138138

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
# see https://github.com/CppCXY/EmmyLuaCodeStyle
3+
[*.lua]
4+
# optional space/tab
5+
indent_style = space
6+
# if indent_style is space, this is valid
7+
indent_size = 4
8+
# if indent_style is tab, this is valid
9+
tab_width = 8
10+
continuation_indent_size = 4
11+
align_call_args = false
12+
keep_one_space_between_call_args_and_bracket = false
13+
align_function_define_params = true
14+
keep_one_space_between_table_and_bracket = true
15+
align_table_field_to_first_field = true
16+
continuous_assign_statement_align_to_equal_sign = true
17+
continuous_assign_table_field_align_to_equal_sign = true
18+
# optional crlf/lf
19+
end_of_line = crlf
20+
21+
# The following configuration supports three expressions
22+
# minLine:${n}
23+
# keepLine
24+
# KeepLine:${n}
25+
26+
keep_line_after_if_statement = minLine:1
27+
keep_line_after_do_statement = minLine:1
28+
keep_line_after_while_statement = minLine:1
29+
keep_line_after_repeat_statement = minLine:1
30+
keep_line_after_for_statement = minLine:1
31+
keep_line_after_local_or_assign_statement = keepLine
32+
keep_line_after_function_define_statement = keepLine:1
33+
34+
# the following is code diagnostic options
35+
enable_check_codestyle = false
36+
# this mean utf8 length
37+
max_line_length = 120
38+
# this will check text end with new line(format always end with new line)
39+
insert_final_newline = true
40+
41+
42+
enable_name_style_check = true
43+
# the following is name style check rule
44+
# base option off/camel_case/snake_case/upper_snake_case/pascal_case/same(filename/first_param/'<const string>', snake_case/pascal_case/camel_case)
45+
# all option can use '|' represent or
46+
# for example:
47+
# snake_case | upper_snake_case
48+
# same(first_param, snake_case)
49+
# same('m')
50+
local_name_define_style = snake_case
51+
function_param_name_style = snake_case
52+
function_name_define_style = snake_case
53+
local_function_name_define_style = snake_case
54+
table_field_name_define_style = snake_case
55+
global_variable_name_define_style = snake_case|upper_snake_case
56+
module_name_define_style = same('m')|same(filename, snake_case)
57+
require_module_name_style = same(first_param, snake_case)
58+
class_name_define_style = same(filename, snake_case)
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
--local
2+
local requireA = require "aaa.bbb.ccc"
3+
4+
local ccc = aaa+bbbb
5+
local ddd = aaa+eee
6+
+ eeee
7+
8+
local f = function() end
9+
local cc2= function()
10+
end
11+
12+
13+
--cotinuous
14+
local aa = 123
15+
local ddd = 456
16+
local d13131 = 131
17+
18+
19+
--do
20+
do return end
21+
22+
do
23+
return function ()
24+
25+
end
26+
end
27+
28+
--function
29+
function f(aaa,bbbb)
30+
end
31+
32+
local function fff2(aaa,ddd)
33+
-- body
34+
end
35+
36+
--for
37+
38+
for i,v in pairs({1,2,3,4,5}) do
39+
print(i,v)
40+
end
41+
42+
for i=1,10,10 do
43+
end
44+
45+
-- while
46+
47+
while true do
48+
print("123")
49+
end
50+
51+
--repeat
52+
53+
repeat
54+
do return end
55+
until true
56+
57+
--table
58+
local c = {
59+
60+
}
61+
local d = { 1, 2, 3 }
62+
local e = {
63+
aa = 123, bb = 456,
64+
ddd = 789 + 12313, --hi
65+
--[[
66+
hello
67+
]]
68+
eee_ccc =123
69+
}
70+
71+
--call
72+
73+
require"empty"
74+
require("empty2")
75+
print(1,2,3,
76+
5, 6, 7)
77+
78+
79+
--if
80+
if true then
81+
else
82+
ddd =123
83+
end
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
--local
2+
local requireA = require "aaa.bbb.ccc"
3+
4+
local ccc = aaa + bbbb
5+
local ddd = aaa + eee
6+
+ eeee
7+
8+
local f = function() end
9+
local cc2 = function()
10+
end
11+
--do
12+
--local
13+
local requireA = require "aaa.bbb.ccc"
14+
15+
local ccc = aaa + bbbb
16+
local ddd = aaa + eee
17+
+ eeee
18+
19+
local f = function() end
20+
local cc2 = function()
21+
end
22+
23+
24+
--cotinuous
25+
local aa = 123
26+
local ddd = 456
27+
local d13131 = 131
28+
29+
30+
--do
31+
do return end
32+
33+
do
34+
return function()
35+
36+
end
37+
end
38+
39+
--function
40+
function f(aaa, bbbb)
41+
end
42+
43+
local function fff2(aaa, ddd)
44+
-- body
45+
end
46+
47+
--for
48+
49+
for i, v in pairs({ 1, 2, 3, 4, 5 }) do
50+
print(i, v)
51+
end
52+
53+
for i = 1, 10, 10 do
54+
end
55+
56+
-- while
57+
58+
while true do
59+
print("123")
60+
end
61+
62+
--repeat
63+
64+
repeat
65+
do return end
66+
until true
67+
68+
--table
69+
local c = {
70+
71+
}
72+
local d = { 1, 2, 3 }
73+
local e = {
74+
aa = 123, bb = 456,
75+
ddd = 789 + 12313, --hi
76+
--[[
77+
hello
78+
]]
79+
eee_ccc = 123
80+
}
81+
82+
--call
83+
84+
require "empty"
85+
require("empty2")
86+
print(1, 2, 3,
87+
5, 6, 7)
88+
89+
90+
--if
91+
if true then
92+
else
93+
ddd = 123
94+
end

0 commit comments

Comments
 (0)