Skip to content

Commit

Permalink
fix make_len, improve go2v_test.v, comment out complex_tests for now (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
JalonSolov authored Feb 22, 2025
1 parent 836bd66 commit c690008
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ z
#Intellij IDEA
.idea/
*.iml
#VSCode
.vscode/

#Temp conversion files
**/*.json
7 changes: 5 additions & 2 deletions fn_call.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ fn (mut app App) call_expr(call CallExpr) {
// fmt.Println => println
fun := call.fun
if fun is SelectorExpr {
if fun.x is Ident {
if fun.sel.name == 'String' && fun.x is CallExpr {
app.expr(fun.x)
app.gen('.str()')
return
} else if fun.x is Ident {
if fun.x.name == 'fmt' && fun.sel.name in ['Println', 'Print'] {
fn_name = fun.sel.name.to_lower()
is_println = true
Expand Down Expand Up @@ -149,7 +153,6 @@ fn (mut app App) selector_xxx(sel SelectorExpr) {

fn (mut app App) make_call(call CallExpr) {
// app.genln('//make ${call.fun.type_name()} ar0=${call.args[0].type_name()}')
app.force_upper = true
app.expr(call.args[0])
// len only
if call.args.len == 2 {
Expand Down
47 changes: 28 additions & 19 deletions go2v_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,47 @@ import strings
import os

fn test_all() {
subdir := 'tests'
mut app := &App{
sb: strings.new_builder(1000)
}

// All tests
mut tests_to_run := map[string][]string{}
mut tests_failures := []string{}

mut test_names := os.ls('tests') or { return }
test_names.sort()
mut tests_failures := []string{}
complex_names := os.ls('complex_tests/esbuild') or { return }
assert complex_names.len > 0
test_names << complex_names
for test_name in test_names {
println('='.repeat(44))
create_json(subdir, test_name)
// A separate instance for each test
mut app2 := &App{
sb: strings.new_builder(1000)
}
app2.run_test(subdir, test_name) or {
eprintln('Error running test ${test_name}: ${err}')
exit(1)
}
if !app2.tests_ok {
tests_failures << test_name
tests_to_run['tests'] = test_names

// mut complex_names := os.ls('complex_tests/esbuild') or { return }
// if complex_names.len > 0 {
// complex_names.sort()
// tests_to_run['complex_tests/esbuild'] = complex_names
// }

for subdir, tests in tests_to_run {
for test_name in tests {
println('='.repeat(44))
create_json(subdir, test_name)
// A separate instance for each test
mut app2 := &App{
sb: strings.new_builder(1000)
}
app2.run_test(subdir, test_name) or {
eprintln('Error running test ${test_name}: ${err}')
exit(1)
}
if !app2.tests_ok {
tests_failures << '${subdir}/${test_name}'
}
}
}

if tests_failures.len != 0 {
eprintln('='.repeat(80))
eprintln('Found ${tests_failures.len} go2v errors. Use the following commands to reproduce them in isolation:')
for f in tests_failures {
eprintln(' ./go2v ${subdir}/${f}')
eprintln(' ./go2v ${f}')
}
exit(1)
}
Expand Down
3 changes: 0 additions & 3 deletions stmt.v
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ fn (mut app App) if_stmt(node IfStmt) {
// else {
else if node.else_ is BlockStmt {
app.genln('else')
if node.else_.list.len > 0 && node.else_.list[0] is IfStmt {
app.genln('//LOOL')
}
app.block_stmt(node.else_)
}
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit c690008

Please sign in to comment.