mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
run vfmt on math and sha; add vfmt check to test-compiler
This commit is contained in:
@ -2513,7 +2513,7 @@ fn (p mut Parser) array_init() string {
|
||||
const_name := p.prepend_mod(p.lit)
|
||||
if p.table.known_const(const_name) {
|
||||
c := p.table.find_const(const_name) or {
|
||||
// p.error('unknown const `$p.lit`')
|
||||
p.error('unknown const `$const_name`')
|
||||
exit(1)
|
||||
}
|
||||
if c.typ == 'int' && p.peek() == .rsbr {
|
||||
@ -2582,8 +2582,9 @@ fn (p mut Parser) array_init() string {
|
||||
}
|
||||
if p.tok != .rsbr && p.tok != .semicolon {
|
||||
p.gen(', ')
|
||||
line_nr := p.tok
|
||||
p.check(.comma)
|
||||
p.fspace()
|
||||
p.fspace_or_newline()
|
||||
}
|
||||
i++
|
||||
// Repeat (a = [0;5] )
|
||||
|
@ -2,34 +2,35 @@ module main
|
||||
|
||||
import os
|
||||
import term
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/// This file will get compiled as part of the main program,
|
||||
/// for a _test.v file.
|
||||
/// The methods defined here are called back by the test program's
|
||||
/// assert statements, on each success/fail. The goal is to make
|
||||
/// customizing the look & feel of the assertions results easier,
|
||||
/// since it is done in normal V code, instead of in embedded C ...
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
fn cb_assertion_failed(filename string, line int, sourceline string, funcname string){
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// / This file will get compiled as part of the main program,
|
||||
// / for a _test.v file.
|
||||
// / The methods defined here are called back by the test program's
|
||||
// / assert statements, on each success/fail. The goal is to make
|
||||
// / customizing the look & feel of the assertions results easier,
|
||||
// / since it is done in normal V code, instead of in embedded C ...
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
fn cb_assertion_failed(filename string, line int, sourceline string, funcname string) {
|
||||
color_on := term.can_show_color_on_stderr()
|
||||
use_relative_paths := match os.getenv('VERROR_PATHS') {
|
||||
'absolute' { false }
|
||||
else { true }
|
||||
}
|
||||
final_filename := if use_relative_paths { filename } else { os.realpath( filename ) }
|
||||
final_funcname := funcname.replace('main__','').replace('__','.')
|
||||
|
||||
'absolute'{
|
||||
false
|
||||
}
|
||||
else {
|
||||
true}}
|
||||
final_filename := if use_relative_paths { filename } else { os.realpath(filename) }
|
||||
final_funcname := funcname.replace('main__', '').replace('__', '.')
|
||||
mut fail_message := 'FAILED assertion'
|
||||
if color_on { fail_message = term.bold(term.red(fail_message)) }
|
||||
|
||||
if color_on {
|
||||
fail_message = term.bold(term.red(fail_message))
|
||||
}
|
||||
eprintln('$final_filename:$line: $fail_message')
|
||||
eprintln('Function: $final_funcname')
|
||||
eprintln('Source : $sourceline')
|
||||
}
|
||||
|
||||
fn cb_assertion_ok(filename string, line int, sourceline string, funcname string){
|
||||
//do nothing for now on an OK assertion
|
||||
//println('OK ${line:5d}|$sourceline ')
|
||||
fn cb_assertion_ok(filename string, line int, sourceline string, funcname string) {
|
||||
// do nothing for now on an OK assertion
|
||||
// println('OK ${line:5d}|$sourceline ')
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,19 @@ fn (p mut Parser) fspace() {
|
||||
p.fgen(' ')
|
||||
}
|
||||
|
||||
[if vfmt]
|
||||
fn (p mut Parser) fspace_or_newline() {
|
||||
if p.first_pass() {
|
||||
return
|
||||
}
|
||||
if p.token_idx >= 2 && p.tokens[p.token_idx-1].line_nr !=
|
||||
p.tokens[p.token_idx-2].line_nr {
|
||||
p.fgen_nl()
|
||||
} else {
|
||||
p.fgen(' ')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[if vfmt]
|
||||
fn (p mut Parser) fgenln(s string) {
|
||||
|
Reference in New Issue
Block a user