fmt: fix formating a file in an oscillating manner (fix #22223, fix #22026) (#22232)

This commit is contained in:
yuyi 2024-09-17 14:47:38 +08:00 committed by GitHub
parent c004d0c899
commit acf6b344f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
99 changed files with 681 additions and 655 deletions

View file

@ -157,18 +157,18 @@ jobs:
echo "Build v-analyzer release"
v build.vsh release
- name: Format vlang/v-analyzer
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
run: |
cd /tmp/v-analyzer
set +e
v fmt -c .
exit_code=$?
if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then
# Don't fail if there are only internal errors (exit code 5).
v fmt -diff .
exit 1
fi
# - name: Format vlang/v-analyzer
# if: ${{ !cancelled() && steps.build.outcome == 'success' }}
# run: |
# cd /tmp/v-analyzer
# set +e
# v fmt -c .
# exit_code=$?
# if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then
# # Don't fail if there are only internal errors (exit code 5).
# v fmt -diff .
# exit 1
# fi
- name: Build vlang/go2v
if: ${{ !cancelled() && steps.build.outcome == 'success' && matrix.os != 'macos-14' }}

View file

@ -89,10 +89,10 @@ fn process_files(files []string) ! {
fn new_parser(path string, comments_mode scanner.CommentsMode, table &ast.Table, pref_ &pref.Preferences) &parser.Parser {
mut p := &parser.Parser{
scanner: scanner.new_scanner_file(path, comments_mode, pref_) or { panic(err) }
table: table
pref: pref_
scope: &ast.Scope{
scanner: scanner.new_scanner_file(path, comments_mode, pref_) or { panic(err) }
table: table
pref: pref_
scope: &ast.Scope{
start_pos: 0
parent: table.global_scope
}

View file

@ -87,10 +87,10 @@ fn process_files(files []string) ! {
fn new_parser(path string, comments_mode scanner.CommentsMode, table &ast.Table, pref_ &pref.Preferences) &parser.Parser {
mut p := &parser.Parser{
scanner: scanner.new_scanner_file(path, comments_mode, pref_) or { panic(err) }
table: table
pref: pref_
scope: &ast.Scope{
scanner: scanner.new_scanner_file(path, comments_mode, pref_) or { panic(err) }
table: table
pref: pref_
scope: &ast.Scope{
start_pos: 0
parent: table.global_scope
}

View file

@ -22,8 +22,8 @@ struct BumpTestCase {
const test_cases = [
BumpTestCase{
file_name: 'v.mod'
contents: "Module {
file_name: 'v.mod'
contents: "Module {
name: 'Sample'
description: 'Sample project'
version: '1.2.6'
@ -38,8 +38,8 @@ const test_cases = [
expected_major: " version: '2.0.0'"
},
BumpTestCase{
file_name: 'random_versions.vv'
contents: "
file_name: 'random_versions.vv'
contents: "
1.1.2
1.2.5
3.21.73
@ -52,8 +52,8 @@ version = '1.5.1'
expected_major: "version = '2.0.0'"
},
BumpTestCase{
file_name: 'sample_tool.v'
contents: "// Module comment and copyright information
file_name: 'sample_tool.v'
contents: "// Module comment and copyright information
import os
import flag
@ -110,8 +110,8 @@ struct SkipTestCase {
const skip_test_cases = [
SkipTestCase{
file_name: 'CITATION.cff'
contents: 'abstract: A sample CLI tool made in V that prints geometric shapes to the screen.
file_name: 'CITATION.cff'
contents: 'abstract: A sample CLI tool made in V that prints geometric shapes to the screen.
authors:
- alias: hungrybluedev
family-names: Haldar

View file

@ -50,7 +50,7 @@ fn main() {
},
]
mut cmd := Command{
flags: [
flags: [
Flag{
flag: .bool
name: 'help'
@ -70,7 +70,7 @@ fn main() {
'The <project_name> argument can be omitted and entered in the prompts dialog.',
'If git is installed, `git init` will be performed during the setup.',
].join_lines()
parent: &Command{
parent: &Command{
name: 'v'
}
posix_mode: true
@ -87,7 +87,7 @@ fn main() {
'If no `.v` file exists, a project template is generated. If the current directory is not a',
'git project and git is installed, `git init` will be performed during the setup.',
].join_lines()
parent: &Command{
parent: &Command{
name: 'v'
}
posix_mode: true

View file

@ -10,7 +10,7 @@ mut:
// Default ignore patterns.
'': ['testdata', 'tests', '*_test.v']
}
paths map[string]bool
paths map[string]bool
}
fn get_modules(path string) []string {

View file

@ -155,7 +155,7 @@ fn (mut vd VDoc) create_search_results(mod string, dn doc.DocNode, out Output) {
dn_description := trim_doc_node_description(dn.name, comments)
vd.search_index << dn.name
vd.search_data << SearchResult{
prefix: if dn.parent_name != '' {
prefix: if dn.parent_name != '' {
'${dn.kind} (${dn.parent_name})'
} else {
'${dn.kind} '

View file

@ -299,7 +299,7 @@ fn (mut vd VDoc) generate_docs_from_file() {
println(markdown.to_plain(readme_contents))
} else if out.typ == .html && cfg.is_multi {
vd.docs << doc.Doc{
head: doc.DocNode{
head: doc.DocNode{
name: 'README'
comments: [comment]
}

View file

@ -87,7 +87,7 @@ fn new_repl(folder string) Repl {
vstartup_source := os.read_file(vstartup) or { '' }.trim_right('\n\r').split_into_lines()
os.mkdir_all(folder) or {}
return Repl{
readline: readline.Readline{
readline: readline.Readline{
skip_empty: true
}
folder: folder

View file

@ -827,7 +827,7 @@ fn on_event(e &gg.Event, mut app App) {
if e.num_touches > 0 {
t := e.touches[0]
app.touch.start = Touch{
pos: Pos{
pos: Pos{
x: int(t.pos_x / app.ui.dpi_scale)
y: int(t.pos_y / app.ui.dpi_scale)
}
@ -839,7 +839,7 @@ fn on_event(e &gg.Event, mut app App) {
if e.num_touches > 0 {
t := e.touches[0]
app.touch.end = Touch{
pos: Pos{
pos: Pos{
x: int(t.pos_x / app.ui.dpi_scale)
y: int(t.pos_y / app.ui.dpi_scale)
}
@ -850,7 +850,7 @@ fn on_event(e &gg.Event, mut app App) {
}
.mouse_down {
app.touch.start = Touch{
pos: Pos{
pos: Pos{
x: int(e.mouse_x / app.ui.dpi_scale)
y: int(e.mouse_y / app.ui.dpi_scale)
}
@ -859,7 +859,7 @@ fn on_event(e &gg.Event, mut app App) {
}
.mouse_up {
app.touch.end = Touch{
pos: Pos{
pos: Pos{
x: int(e.mouse_x / app.ui.dpi_scale)
y: int(e.mouse_y / app.ui.dpi_scale)
}

View file

@ -31,10 +31,10 @@ const second_hand_color = gx.red
struct App {
minutes_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw,
tp + 1 * th, center - tw, tp + 1 * th]
hours_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, tp + 2 * th,
center - tw, tp + 2 * th]
hours3_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, tp + 3 * th,
center - tw, tp + 3 * th]
hours_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw,
tp + 2 * th, center - tw, tp + 2 * th]
hours3_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw,
tp + 3 * th, center - tw, tp + 3 * th]
hour_hand []f32 = [f32(329), 161, 350, 140, 371, 161, 371, 413, 329, 413]
minute_hand []f32 = [f32(334.25), 40.25, 350, 24.5, 365.75, 40.25, 365.75, 427, 334.25, 427]

View file

@ -53,7 +53,7 @@ pub fn new_rocket() Rocket {
pos: Vector{
x: rand.f32_in_range(50, get_params().width - 50) or { 50 }
}
vel: Vector{
vel: Vector{
x: rand.f32_in_range(-1.5, 1.5) or { -1.5 }
y: rand.f32_in_range(5, 7) or { 5 }
}

View file

@ -57,9 +57,9 @@ fn frame(mut app App) {
description: 'Hello! This should show an *animated* example application description.
We are at frame ${app.frame}.
Press ESCAPE or Ctrl+C to exit'
footer: '
footer: '
Press ESCAPE or Ctrl+C to exit'
fields: {
fields: {
'level': 'Level of lorem ipsum\nand more\nmany many many more.\nNotice how user newlines/format is kept since\ninput lines are all less or within\nthe default layout.description_padding\nand max width'
'example': 'Looong example text without newlines or anything else and lorem ipsum and more and many many many more. Should be auto fitted'
'multi': 'This flag can be repeated'

View file

@ -209,11 +209,11 @@ Editing property: ${app.edit}, value: ${value}')
help_text := flag.to_doc[DocTest](
description: 'Simple DocLayout editor.
Press ESCAPE or Ctrl+C to exit and print layout code'
footer: '
footer: '
Press ESCAPE or Ctrl+C to exit and print layout code'
fields: unsafe { field_docs }
layout: app.layout
options: app.options
fields: unsafe { field_docs }
layout: app.layout
options: app.options
) or { '' }
app.tui.draw_text(0, 5, '${help_text}')

View file

@ -42,8 +42,8 @@ pub fn (mut window Window) draw(_ voidptr) {
x: myconfig.img_rect.x + f32(math.sin(f32(window.ctx.frame) / 10.0) * 60)
y: myconfig.img_rect.y + f32(math.cos(f32(window.ctx.frame) / 10.0) * 60)
}
color: gx.Color{255, 0, 0, 255}
effect: .add
color: gx.Color{255, 0, 0, 255}
effect: .add
})
// Green
@ -54,8 +54,8 @@ pub fn (mut window Window) draw(_ voidptr) {
x: myconfig.img_rect.x + f32(math.sin(f32(window.ctx.frame) / 10.0) * 80)
y: myconfig.img_rect.y + f32(math.cos(f32(window.ctx.frame) / 10.0) * 80)
}
color: gx.Color{0, 255, 0, 255}
effect: .add
color: gx.Color{0, 255, 0, 255}
effect: .add
})
// Blue
@ -66,8 +66,8 @@ pub fn (mut window Window) draw(_ voidptr) {
x: myconfig.img_rect.x + f32(math.sin(f32(window.ctx.frame) / 10.0) * 100)
y: myconfig.img_rect.y + f32(math.cos(f32(window.ctx.frame) / 10.0) * 100)
}
color: gx.Color{0, 0, 255, 255}
effect: .add
color: gx.Color{0, 0, 255, 255}
effect: .add
})
// More examples
@ -78,8 +78,8 @@ pub fn (mut window Window) draw(_ voidptr) {
x: 50
y: 0
}
color: gx.Color{255, 0, 0, 255}
effect: .add
color: gx.Color{255, 0, 0, 255}
effect: .add
})
window.ctx.draw_image_with_config(gg.DrawImageConfig{
@ -89,8 +89,8 @@ pub fn (mut window Window) draw(_ voidptr) {
x: 50
y: 50
}
color: gx.Color{0, 255, 0, 255}
effect: .add
color: gx.Color{0, 255, 0, 255}
effect: .add
})
window.ctx.draw_image_with_config(gg.DrawImageConfig{
@ -100,8 +100,8 @@ pub fn (mut window Window) draw(_ voidptr) {
x: 50
y: 100
}
color: gx.Color{0, 0, 255, 255}
effect: .add
color: gx.Color{0, 0, 255, 255}
effect: .add
})
window.ctx.end()

View file

@ -45,7 +45,7 @@ fn rain(mut app App) {
init_fn: fn (mut app App) {
gg.toggle_fullscreen()
}
event_fn: fn (event &gg.Event, mut app App) {
event_fn: fn (event &gg.Event, mut app App) {
vprintln('event.typ: ${event.typ} | event.char_code: ${event.char_code}')
if event.typ == .resized {
app.should_calc = true
@ -63,7 +63,7 @@ fn rain(mut app App) {
app.delay = if new_delay > 0 { new_delay } else { 0 }
}
}
frame_fn: frame
frame_fn: frame
)
app.ctx.run()
}
@ -146,7 +146,7 @@ fn draw_rain_column(rc RainColumn, app App) {
b: if at_head { u8(255) } else { 0 }
a: alpha
}
mono: true
mono: true
}
if i < rc.drops.len {
app.ctx.draw_text(x, y, rc.drops[i].ascii_str(), cfg)

View file

@ -335,7 +335,7 @@ fn astar_path_finding(mut app App, mut grid [][]Cell, start Point, end Point) {
x: start.x
y: start.y
}
count: 0
count: 0
})
for priority_queue.len() > 0 {

View file

@ -51,7 +51,7 @@ fn main() {
}
my_app.tray_info = C.tray_app_init(TrayParams{
items: [TrayMenuItem{
items: [TrayMenuItem{
id: 'hello'
text: 'Hello'
}, TrayMenuItem{

View file

@ -21,7 +21,7 @@ const params_test_mock_state = SimState{
y: -12.559375680227724
z: -105.91539687686381
)
accel: vector(
accel: vector(
x: -8.337034766251843e-11
y: -2.842170943040401e-10
z: 1.2126596023639044e-10

View file

@ -19,7 +19,7 @@ const sim_test_mock_state = SimState{
y: -12.559375680227724
z: -105.91539687686381
)
accel: vector(
accel: vector(
x: -8.337034766251843e-11
y: -2.842170943040401e-10
z: 1.2126596023639044e-10

View file

@ -19,7 +19,7 @@ const worker_test_mock_state = SimState{
y: -12.559375680227724
z: -105.91539687686381
)
accel: vector(
accel: vector(
x: -8.337034766251843e-11
y: -2.842170943040401e-10
z: 1.2126596023639044e-10
@ -43,7 +43,7 @@ fn test_compute_result() {
y: -12.55937568022536
z: -105.91539687684447
)
accel: vector(
accel: vector(
x: -1.1368683772161603e-11
y: -1.5916157281026244e-10
z: 0

View file

@ -88,10 +88,10 @@ pub mut:
ka m4.Vec4 = m4.Vec4{
e: [f32(0.1), 0.0, 0.0, 1.0]!
}
kd m4.Vec4 = m4.Vec4{
kd m4.Vec4 = m4.Vec4{
e: [f32(0.5), 0.5, 0.5, 1.0]!
}
ks m4.Vec4 = m4.Vec4{
ks m4.Vec4 = m4.Vec4{
e: [f32(1.0), 1.0, 1.0, 1.0]!
}
}

View file

@ -64,6 +64,6 @@ fn main() {
icon: sapp.IconDesc{
sokol_default: true
}
user_data: &State{}
user_data: &State{}
})
}

View file

@ -78,7 +78,7 @@ fn data_get() []SiteConfig {
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_marketplace'
domains: ['now.threefold.io', 'marketplace.threefold.io', 'now.threefold.me',
'marketplace.threefold.me']
descr: 'apps for community builders, runs on top of evdc'
descr: 'apps for community builders, runs on top of evdc'
},
SiteConfig{
name: 'www_conscious_internet'
@ -90,7 +90,7 @@ fn data_get() []SiteConfig {
path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_conscious_internet'
domains: ['www.consciousinternet.org', 'eco.threefold.io', 'community.threefold.io',
'eco.threefold.me', 'community.threefold.me']
descr: 'community around threefold, partners, friends, ...'
descr: 'community around threefold, partners, friends, ...'
},
SiteConfig{
name: 'www_threefold_tech'

View file

@ -58,7 +58,7 @@ fn (mut v Vec) randomize(min_x int, min_y int, max_x int, max_y int) {
// part of snake's body representation
struct BodyPart {
mut:
pos Vec = Vec{
pos Vec = Vec{
x: block_size
y: block_size
}
@ -239,7 +239,7 @@ fn (s Snake) draw() {
// rat representation
struct Rat {
mut:
pos Vec = Vec{
pos Vec = Vec{
x: block_size
y: block_size
}

View file

@ -22,7 +22,7 @@ fn main() {
println('hello app')
return
}
commands: [
commands: [
cli.Command{
name: 'sub'
execute: fn (cmd cli.Command) ! {

View file

@ -14,7 +14,7 @@ fn test_help_message() {
description: 'another subcommand'
},
]
flags: [
flags: [
Flag{
flag: .string
name: 'str'

View file

@ -14,7 +14,7 @@ fn test_manpage() {
description: 'another subcommand'
},
]
flags: [
flags: [
Flag{
flag: .string
name: 'str'

View file

@ -43,7 +43,7 @@ struct TestCase {
const test_cases = [
// chunk 0 with 0 bytes input
TestCase{
input: TestInput{
input: TestInput{
input_string: ''
key_words: iv
chunk_number: 0
@ -55,13 +55,13 @@ const test_cases = [
block_words: [u32(0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
flags: 0x0b
}
words: [u32(0xb94913af), 0xa6a1f9f5, 0xea4d40a0, 0x49c9dc36, 0xc925cb9b, 0xb712c1ad,
words: [u32(0xb94913af), 0xa6a1f9f5, 0xea4d40a0, 0x49c9dc36, 0xc925cb9b, 0xb712c1ad,
0xca939acc, 0x62321fe4, 0xe7030fe0, 0x6bf29ab6, 0x9ff0aa7f, 0x503033cd, 0xe0df8d33,
0x86ccb885, 0x208ba99c, 0x3a24086c]
},
// chunk 0 with 1 byte input
TestCase{
input: TestInput{
input: TestInput{
input_string: 'A'
key_words: iv
chunk_number: 0
@ -73,13 +73,13 @@ const test_cases = [
block_words: [u32(0x00000041), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
flags: 0x0b
}
words: [u32(0xfa4b6832), 0x4dc8c028, 0x1105216f, 0xfc0eceaa, 0x88c77151, 0x89ba4891,
words: [u32(0xfa4b6832), 0x4dc8c028, 0x1105216f, 0xfc0eceaa, 0x88c77151, 0x89ba4891,
0xa25a8d20, 0x98fa0597, 0x4c0088e3, 0xafa7cbb8, 0xc586c5f7, 0x66dbef0e, 0x8c91d56a,
0xa0b3daff, 0xe919be05, 0x997a1ce7]
},
// chunk 0 with 3 bytes input
TestCase{
input: TestInput{
input: TestInput{
input_string: 'abc'
key_words: iv
chunk_number: 0
@ -91,13 +91,13 @@ const test_cases = [
block_words: [u32(0x00636261), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
flags: 0x0b
}
words: [u32(0xacb33764), 0x33514638, 0x753bb6ff, 0xb58d3a27, 0x4658c548, 0x03db795d,
words: [u32(0xacb33764), 0x33514638, 0x753bb6ff, 0xb58d3a27, 0x4658c548, 0x03db795d,
0x6c9c35fd, 0x859dbdd5, 0xae50b21f, 0xd0f59373, 0x5db61328, 0x490d1a52, 0x9ca09b2d,
0x4c7fcef7, 0xf200d9ff, 0x0bbf7433]
},
// chunk 0 with 63 bytes input
TestCase{
input: TestInput{
input: TestInput{
input_string: ll[..63]
key_words: iv
chunk_number: 0
@ -109,15 +109,15 @@ const test_cases = [
block_words: [u32(0x44434241), 0x48474645, 0x4c4b4a49, 0x504f4e4d, 0x54535251,
0x58575655, 0x61205a59, 0x65646362, 0x69686766, 0x6d6c6b6a, 0x71706f6e, 0x75747372,
0x79787776, 0x3130207a, 0x35343332, 0x00383736]
flags: 0x0b
flags: 0x0b
}
words: [u32(0x39c41fc6), 0x2dd7c57b, 0xb8b16421, 0x360cbedb, 0x462d5672, 0x56713bb5,
words: [u32(0x39c41fc6), 0x2dd7c57b, 0xb8b16421, 0x360cbedb, 0x462d5672, 0x56713bb5,
0x15132543, 0x7a92c4ba, 0x15c4ac13, 0x2354f573, 0xdc14f100, 0x35be07e8, 0xf98b17b9,
0x573f38f8, 0xc8d2fbf4, 0xc06588e5]
},
// chunk 0 with 64 bytes input
TestCase{
input: TestInput{
input: TestInput{
input_string: ll[..64]
key_words: iv
chunk_number: 0
@ -129,15 +129,15 @@ const test_cases = [
block_words: [u32(0x44434241), 0x48474645, 0x4c4b4a49, 0x504f4e4d, 0x54535251,
0x58575655, 0x61205a59, 0x65646362, 0x69686766, 0x6d6c6b6a, 0x71706f6e, 0x75747372,
0x79787776, 0x3130207a, 0x35343332, 0x39383736]
flags: 0x0b
flags: 0x0b
}
words: [u32(0x6010817a), 0x21deb495, 0x0826485b, 0x6f895da5, 0x9363242a, 0x176b60a9,
words: [u32(0x6010817a), 0x21deb495, 0x0826485b, 0x6f895da5, 0x9363242a, 0x176b60a9,
0x383215a7, 0x2b95570f, 0x57fe7082, 0x45b13a10, 0x007af189, 0x4b5e7ec7, 0x9574b5d8,
0x109362a0, 0x282d14c2, 0x3a134380]
},
// chunk 0 with 65 bytes input
TestCase{
input: TestInput{
input: TestInput{
input_string: ll[..65]
key_words: iv
chunk_number: 0
@ -147,16 +147,16 @@ const test_cases = [
chunk_number: 0
chaining_value: [u32(0xbb99f549), 0x3b4b2903, 0x436d199e, 0x6eea5980, 0x82ebb968,
0x33cc3c4a, 0x90f4944b, 0x9480e10a]
block_words: [u32(0x00000020), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
flags: 0x0a
block_words: [u32(0x00000020), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
flags: 0x0a
}
words: [u32(0xb06cf0f5), 0xd6f8f23d, 0x0f06389e, 0x20dec0a4, 0x69a20569, 0xdbbb4453,
words: [u32(0xb06cf0f5), 0xd6f8f23d, 0x0f06389e, 0x20dec0a4, 0x69a20569, 0xdbbb4453,
0x09f0bb52, 0xe22c6707, 0x6b530f62, 0x9ac8bfbd, 0xc0aa57b0, 0xdb30223c, 0xd6e52c79,
0x42d84d38, 0xcfb4105f, 0xb42f1bd3]
},
// chunk 0 with 127 bytes input
TestCase{
input: TestInput{
input: TestInput{
input_string: ll[..127]
key_words: iv
chunk_number: 0
@ -166,18 +166,18 @@ const test_cases = [
chunk_number: 0
chaining_value: [u32(0xbb99f549), 0x3b4b2903, 0x436d199e, 0x6eea5980, 0x82ebb968,
0x33cc3c4a, 0x90f4944b, 0x9480e10a]
block_words: [u32(0x37383920), 0x33343536, 0x20303132, 0x7778797a, 0x73747576, 0x6f707172,
0x6b6c6d6e, 0x6768696a, 0x63646566, 0x5a206162, 0x56575859, 0x52535455, 0x4e4f5051,
0x4a4b4c4d, 0x46474849, 0x00434445]
flags: 0x0a
block_words: [u32(0x37383920), 0x33343536, 0x20303132, 0x7778797a, 0x73747576,
0x6f707172, 0x6b6c6d6e, 0x6768696a, 0x63646566, 0x5a206162, 0x56575859, 0x52535455,
0x4e4f5051, 0x4a4b4c4d, 0x46474849, 0x00434445]
flags: 0x0a
}
words: [u32(0x589a304d), 0x49f8a607, 0x55a03867, 0xe4fec410, 0x1a6bb2f6, 0x11dfecb3,
words: [u32(0x589a304d), 0x49f8a607, 0x55a03867, 0xe4fec410, 0x1a6bb2f6, 0x11dfecb3,
0xf9989552, 0xb2d18382, 0x9fc6329a, 0xcc93199f, 0x5431cfc5, 0x1f5bddc6, 0x1d039fc5,
0x09af900e, 0x55ce0ba2, 0x9707b1e6]
},
// chunk 0 with 128 bytes input
TestCase{
input: TestInput{
input: TestInput{
input_string: ll[..128]
key_words: iv
chunk_number: 0
@ -187,18 +187,18 @@ const test_cases = [
chunk_number: 0
chaining_value: [u32(0xbb99f549), 0x3b4b2903, 0x436d199e, 0x6eea5980, 0x82ebb968,
0x33cc3c4a, 0x90f4944b, 0x9480e10a]
block_words: [u32(0x37383920), 0x33343536, 0x20303132, 0x7778797a, 0x73747576, 0x6f707172,
0x6b6c6d6e, 0x6768696a, 0x63646566, 0x5a206162, 0x56575859, 0x52535455, 0x4e4f5051,
0x4a4b4c4d, 0x46474849, 0x42434445]
flags: 0x0a
block_words: [u32(0x37383920), 0x33343536, 0x20303132, 0x7778797a, 0x73747576,
0x6f707172, 0x6b6c6d6e, 0x6768696a, 0x63646566, 0x5a206162, 0x56575859, 0x52535455,
0x4e4f5051, 0x4a4b4c4d, 0x46474849, 0x42434445]
flags: 0x0a
}
words: [u32(0xd0d12158), 0x8802f9a4, 0x5bd125fb, 0xf2751b9d, 0x8fb2a4d2, 0x27744bfa,
words: [u32(0xd0d12158), 0x8802f9a4, 0x5bd125fb, 0xf2751b9d, 0x8fb2a4d2, 0x27744bfa,
0x6ea287b1, 0xae9cfdb2, 0x8e0c2651, 0xeb2cfa50, 0x84654cbf, 0xb97b6f7b, 0xd2d737a2,
0x46eaad72, 0x4d0235f0, 0xcaf8abb7]
},
// chunk 0 with 129 bytes input
TestCase{
input: TestInput{
input: TestInput{
input_string: ll[..129]
key_words: iv
chunk_number: 0
@ -208,16 +208,16 @@ const test_cases = [
chunk_number: 0
chaining_value: [u32(0xccf04979), 0x9cbf983e, 0x9e274997, 0xb88c707b, 0x482b00d8,
0x7aedc034, 0x1efdc297, 0x4de9f7c5]
block_words: [u32(0x00000041), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
flags: 0x0a
block_words: [u32(0x00000041), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
flags: 0x0a
}
words: [u32(0xa896b53e), 0x1a64b264, 0xb08c7ea7, 0x09990e6d, 0x30470999, 0x762e9f2c,
words: [u32(0xa896b53e), 0x1a64b264, 0xb08c7ea7, 0x09990e6d, 0x30470999, 0x762e9f2c,
0xb6c7bf5f, 0x64fd723a, 0x6cb02e2f, 0xa3849bf2, 0xede8ea18, 0x14c88505, 0xfbf2ad67,
0x6bc0a779, 0x8e731b77, 0x643a82c6]
},
// chunk 0 with 1023 bytes input
TestCase{
input: TestInput{
input: TestInput{
input_string: lb[..1023]
key_words: iv
chunk_number: 0
@ -227,18 +227,18 @@ const test_cases = [
chunk_number: 0
chaining_value: [u32(0x78fd494b), 0xcd7eeddd, 0x0cb98e9b, 0x7a6a754e, 0x38ff2d32,
0x88c4ca4c, 0xbc7baf18, 0xf7684da9]
block_words: [u32(0x207a7978), 0x33323130, 0x37363534, 0x39203938, 0x35363738, 0x31323334,
0x797a2030, 0x75767778, 0x71727374, 0x6d6e6f70, 0x696a6b6c, 0x65666768, 0x61626364,
0x58595a20, 0x54555657, 0x00515253]
flags: 0x0a
block_words: [u32(0x207a7978), 0x33323130, 0x37363534, 0x39203938, 0x35363738,
0x31323334, 0x797a2030, 0x75767778, 0x71727374, 0x6d6e6f70, 0x696a6b6c, 0x65666768,
0x61626364, 0x58595a20, 0x54555657, 0x00515253]
flags: 0x0a
}
words: [u32(0x96bcc611), 0x8ccfc351, 0x89ec78f7, 0x2f748832, 0xf75ee10a, 0xc739f876,
words: [u32(0x96bcc611), 0x8ccfc351, 0x89ec78f7, 0x2f748832, 0xf75ee10a, 0xc739f876,
0x6adddebb, 0xe28853ab, 0x6983883d, 0x1ca0378d, 0x11f4296c, 0x6638ad9a, 0x0c639f8a,
0xebf03d1f, 0x2c0e3844, 0x0989b826]
},
// chunk 0 with 1024 bytes input
TestCase{
input: TestInput{
input: TestInput{
input_string: lb[..1024]
key_words: iv
chunk_number: 0
@ -248,12 +248,12 @@ const test_cases = [
chunk_number: 0
chaining_value: [u32(0x78fd494b), 0xcd7eeddd, 0x0cb98e9b, 0x7a6a754e, 0x38ff2d32,
0x88c4ca4c, 0xbc7baf18, 0xf7684da9]
block_words: [u32(0x207a7978), 0x33323130, 0x37363534, 0x39203938, 0x35363738, 0x31323334,
0x797a2030, 0x75767778, 0x71727374, 0x6d6e6f70, 0x696a6b6c, 0x65666768, 0x61626364,
0x58595a20, 0x54555657, 0x50515253]
flags: 0x0a
block_words: [u32(0x207a7978), 0x33323130, 0x37363534, 0x39203938, 0x35363738,
0x31323334, 0x797a2030, 0x75767778, 0x71727374, 0x6d6e6f70, 0x696a6b6c, 0x65666768,
0x61626364, 0x58595a20, 0x54555657, 0x50515253]
flags: 0x0a
}
words: [u32(0x50dbfcc6), 0x7dd05a7f, 0xa641cc37, 0x11721a4e, 0x6f33eea2, 0x834877a1,
words: [u32(0x50dbfcc6), 0x7dd05a7f, 0xa641cc37, 0x11721a4e, 0x6f33eea2, 0x834877a1,
0x1cb36c9c, 0xf8d78dce, 0xb7539a0e, 0x7c7b57f4, 0xeef982da, 0x82c6c442, 0x8a451e9b,
0xb9cc8414, 0xdef7ad58, 0x65ecfb6b]
},
@ -261,7 +261,7 @@ const test_cases = [
// this is what the second chunk of input sees
// after the first 1024 bytes have been consumed
TestCase{
input: TestInput{
input: TestInput{
input_string: 'O'
key_words: iv
chunk_number: 1
@ -273,7 +273,7 @@ const test_cases = [
block_words: [u32(0x0000004f), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
flags: 0x0b
}
words: [u32(0xfd795319), 0x4448fd94, 0xa8054dbb, 0x526517ad, 0x7e8e2e4c, 0xf54cf835,
words: [u32(0xfd795319), 0x4448fd94, 0xa8054dbb, 0x526517ad, 0x7e8e2e4c, 0xf54cf835,
0xb498c9a7, 0x341396fa, 0x753298b2, 0xd721328c, 0x4013c5d6, 0xaf64d891, 0x77893790,
0xe486143b, 0x13764172, 0x0cae81d0]
},

File diff suppressed because it is too large Load diff

View file

@ -546,7 +546,7 @@ const max_latin_1 = rune(0x00ff)
// Represents all unicode in unicode category L.
const letter_table = RangeTable{
r16: [
r16: [
Range16{0x0041, 0x005a, 1},
Range16{0x0061, 0x007a, 1},
Range16{0x00aa, 0x00b5, 11},
@ -907,7 +907,7 @@ const letter_table = RangeTable{
Range16{0xffd2, 0xffd7, 1},
Range16{0xffda, 0xffdc, 1},
]
r32: [
r32: [
Range32{0x10000, 0x1000b, 1},
Range32{0x1000d, 0x10026, 1},
Range32{0x10028, 0x1003a, 1},
@ -1141,7 +1141,7 @@ const letter_table = RangeTable{
// Represents all unicodes in unicode category Z with property white space.
const white_space_table = RangeTable{
r16: [
r16: [
Range16{0x0009, 0x000d, 1},
Range16{0x0020, 0x0085, 101},
Range16{0x00a0, 0x1680, 5600},
@ -1156,7 +1156,7 @@ const white_space_table = RangeTable{
// Represents all unicodes in unicode category N.
const number_table = RangeTable{
r16: [
r16: [
Range16{0x0030, 0x0039, 1},
Range16{0x00b2, 0x00b3, 1},
Range16{0x00b9, 0x00bc, 3},
@ -1224,7 +1224,7 @@ const number_table = RangeTable{
Range16{0xabf0, 0xabf9, 1},
Range16{0xff10, 0xff19, 1},
]
r32: [
r32: [
Range32{0x10107, 0x10133, 1},
Range32{0x10140, 0x10178, 1},
Range32{0x1018a, 0x1018b, 1},

View file

@ -10,7 +10,7 @@ fn test_node() {
'test:key': ' test_value '
'test:other': '123456'
}
children: [
children: [
xml.XMLNode{
name: 'child'
attributes: {
@ -25,7 +25,7 @@ fn test_node() {
attributes: {
'k': 'v'
}
children: [
children: [
'Hello, world!',
xml.XMLNode{
name: 'c'
@ -41,7 +41,7 @@ fn test_node() {
'uri': '{B58B0392-4F1F-4190-BB64-5DF3571DCE5F}'
'xmlns:xcalcf': 'http://schemas.microsoft.com/office/spreadsheetml/2018/calcfeatures'
}
children: [
children: [
xml.XMLNode{
name: 'xcalcf:calcFeatures'
children: [
@ -130,7 +130,7 @@ fn test_doc() {
'test:key': ' test_value '
'test:other': '123456'
}
children: [
children: [
xml.XMLNode{
name: 'child'
attributes: {
@ -147,7 +147,7 @@ fn test_doc() {
attributes: {
'k': 'v'
}
children: [
children: [
'Hello, world!',
xml.XMLNode{
name: 'c'

View file

@ -31,7 +31,7 @@ const xml_elements = [
attributes: {
'id': 'c2'
}
children: [
children: [
'Sample Text',
]
},
@ -80,7 +80,7 @@ const xml_elements = [
attributes: {
'id': 'c9'
}
children: [
children: [
'More Sample Text',
]
},

View file

@ -36,13 +36,13 @@ fn test_large_gtk_file() ! {
'name': 'new'
'c:identifier': 'gtk_window_new'
}
children: [
children: [
xml.XMLNodeContents(xml.XMLNode{
name: 'doc'
attributes: {
'xml:space': 'preserve'
}
children: [
children: [
xml.XMLNodeContents('Creates a new `GtkWindow`.
To get an undecorated window (no window borders), use
@ -62,13 +62,13 @@ To delete a `GtkWindow`, call [method@Gtk.Window.destroy].'),
attributes: {
'transfer-ownership': 'none'
}
children: [
children: [
xml.XMLNodeContents(xml.XMLNode{
name: 'doc'
attributes: {
'xml:space': 'preserve'
}
children: [xml.XMLNodeContents('a new `GtkWindow`.')]
children: [xml.XMLNodeContents('a new `GtkWindow`.')]
}),
xml.XMLNodeContents(xml.XMLNode{
name: 'type'
@ -76,7 +76,7 @@ To delete a `GtkWindow`, call [method@Gtk.Window.destroy].'),
'name': 'Widget'
'c:type': 'GtkWidget*'
}
children: []
children: []
}),
]
}),

View file

@ -10,7 +10,7 @@ fn test_valid_parsing() ! {
text: ' Employee Information'
},
]
root: xml.XMLNode{
root: xml.XMLNode{
name: 'address'
children: [
xml.XMLComment{

View file

@ -35,7 +35,7 @@ fn test_valid_parsing() {
]
}
}
root: xml.XMLNode{
root: xml.XMLNode{
name: 'note'
children: [
xml.XMLNode{

View file

@ -12,21 +12,21 @@ fn test_valid_parsing() {
attributes: {
'category': 'web'
}
children: [
children: [
xml.XMLNode{
name: 'title'
attributes: {
'lang': 'en'
'code:type': 'const char*'
}
children: ['Learning XML']
children: ['Learning XML']
},
xml.XMLNode{
name: 'author'
attributes: {
'attr': ' surrounding spaces '
}
children: ['Erik T. Ray']
children: ['Erik T. Ray']
},
xml.XMLNode{
name: 'year'

View file

@ -13,7 +13,7 @@ fn test_valid_parsing() {
'count': '5'
'uniqueCount': '5'
}
children: [
children: [
xml.XMLNode{
name: 'si'
children: [
@ -22,7 +22,7 @@ fn test_valid_parsing() {
attributes: {
'a': '1'
}
children: ['Item 1']
children: ['Item 1']
},
]
},

View file

@ -210,4 +210,4 @@ fn main() {
println('an_int: ${an_int} | a_bool: ${a_bool} | a_float: ${a_float} | a_string: "${a_string}" ')
println(additional_args.join_lines())
}
```
```

View file

@ -340,7 +340,7 @@ pub fn to_doc[T](dc DocConfig) !string {
delimiter: dc.delimiter
style: dc.style
}
input: []
input: []
}
fm.si = fm.get_struct_info[T]()!
return fm.to_doc(dc)!

View file

@ -176,20 +176,20 @@ fn test_flag_to_doc_spacing_and_new_lines() {
assert flag.to_doc[DocTest](
description: 'Flag to doc test.
Content here'
footer: '
footer: '
Footer content'
fields: unsafe { field_docs }
fields: unsafe { field_docs }
)! == doc4
// Test in compact mode also
assert flag.to_doc[DocTest](
options: flag.DocOptions{
options: flag.DocOptions{
compact: true
}
description: 'Flag to doc test.
Content here'
footer: '
footer: '
Footer content'
fields: unsafe { field_docs }
fields: unsafe { field_docs }
)! == doc5
}

View file

@ -628,12 +628,12 @@ pub fn (ctx &Context) end(options EndOptions) {
pub struct FPSConfig {
pub mut:
x int // horizontal position on screen
y int // vertical position on screen
width int // minimum width
height int // minimum height
show bool // do not show by default, use `-d show_fps` or set it manually in your app to override with: `app.gg.fps.show = true`
text_config gx.TextCfg = gx.TextCfg{
x int // horizontal position on screen
y int // vertical position on screen
width int // minimum width
height int // minimum height
show bool // do not show by default, use `-d show_fps` or set it manually in your app to override with: `app.gg.fps.show = true`
text_config gx.TextCfg = gx.TextCfg{
color: gx.yellow
size: 20
align: .center

View file

@ -46,4 +46,4 @@ fn main() {
println('JSON encoding of employee y: ${ss}')
assert ss == s
}
```
```

View file

@ -15,8 +15,8 @@ fn test_json_encode_with_ptr() {
name: 'foo'
}
data := MyStruct{
user: &user
users: {
user: &user
users: {
'keyfoo': user
}
users2: {

View file

@ -273,7 +273,7 @@ fn test_nested_type() {
cities: [City{'Donlon'}, City{'Termanches'}]
},
]
users: {
users: {
'Foo': User{
age: 10
nums: [1, 2, 3]
@ -291,7 +291,7 @@ fn test_nested_type() {
pets: 'little boo'
}
}
extra: {
extra: {
'2': {
'n1': 2
'n2': 4
@ -527,7 +527,7 @@ fn test_encoding_struct_with_pointers() {
association: &Association{
price: APrice{}
}
price: APrice{}
price: APrice{}
}
assert json.encode(value) == '{"association":{"price":{}},"price":{}}'
}

View file

@ -29,10 +29,10 @@ mut:
lexical_attributes LexicalAttributes = LexicalAttributes{
current_tag: &Tag{}
}
filename string = 'direct-parse'
initialized bool
tags []&Tag
debug_file os.File
filename string = 'direct-parse'
initialized bool
tags []&Tag
debug_file os.File
}
// This function is used to add a tag for the parser ignore it's content.

View file

@ -21,7 +21,7 @@ const write_set_cookie_tests = [
name: 'cookie-1'
value: 'v1'
}
raw: 'cookie-1=v1'
raw: 'cookie-1=v1'
},
SetCookieTestCase{
cookie: &http.Cookie{
@ -29,7 +29,7 @@ const write_set_cookie_tests = [
value: 'two'
max_age: 3600
}
raw: 'cookie-2=two; Max-Age=3600'
raw: 'cookie-2=two; Max-Age=3600'
},
SetCookieTestCase{
cookie: &http.Cookie{
@ -37,7 +37,7 @@ const write_set_cookie_tests = [
value: 'three'
domain: '.example.com'
}
raw: 'cookie-3=three; domain=example.com'
raw: 'cookie-3=three; domain=example.com'
},
SetCookieTestCase{
cookie: &http.Cookie{
@ -45,7 +45,7 @@ const write_set_cookie_tests = [
value: 'four'
path: '/restricted/'
}
raw: 'cookie-4=four; path=/restricted/'
raw: 'cookie-4=four; path=/restricted/'
},
SetCookieTestCase{
cookie: &http.Cookie{
@ -53,7 +53,7 @@ const write_set_cookie_tests = [
value: 'five'
domain: 'wrong;bad.abc'
}
raw: 'cookie-5=five'
raw: 'cookie-5=five'
},
SetCookieTestCase{
cookie: &http.Cookie{
@ -61,7 +61,7 @@ const write_set_cookie_tests = [
value: 'six'
domain: 'bad-.abc'
}
raw: 'cookie-6=six'
raw: 'cookie-6=six'
},
// SetCookieTestCase{
// cookie: &http.Cookie{name: 'cookie-7', value: 'seven', domain: '127.0.0.1'},
@ -73,7 +73,7 @@ const write_set_cookie_tests = [
value: 'eight'
domain: '::1'
}
raw: 'cookie-8=eight'
raw: 'cookie-8=eight'
},
// {
// cookie: &http.Cookie{name: 'cookie-9', value: 'expiring', expires: time.unix(1257894000, 0)},
@ -94,7 +94,7 @@ const write_set_cookie_tests = [
value: 'samesite-default'
same_site: .same_site_default_mode
}
raw: 'cookie-12=samesite-default; SameSite'
raw: 'cookie-12=samesite-default; SameSite'
},
SetCookieTestCase{
cookie: &http.Cookie{
@ -102,7 +102,7 @@ const write_set_cookie_tests = [
value: 'samesite-lax'
same_site: .same_site_lax_mode
}
raw: 'cookie-13=samesite-lax; SameSite=Lax'
raw: 'cookie-13=samesite-lax; SameSite=Lax'
},
SetCookieTestCase{
cookie: &http.Cookie{
@ -110,7 +110,7 @@ const write_set_cookie_tests = [
value: 'samesite-strict'
same_site: .same_site_strict_mode
}
raw: 'cookie-14=samesite-strict; SameSite=Strict'
raw: 'cookie-14=samesite-strict; SameSite=Strict'
},
SetCookieTestCase{
cookie: &http.Cookie{
@ -118,7 +118,7 @@ const write_set_cookie_tests = [
value: 'samesite-none'
same_site: .same_site_none_mode
}
raw: 'cookie-15=samesite-none; SameSite=None'
raw: 'cookie-15=samesite-none; SameSite=None'
},
// The 'special' cookies have values containing commas or spaces which
// are disallowed by RFC 6265 but are common in the wild.
@ -127,102 +127,102 @@ const write_set_cookie_tests = [
name: 'special-1'
value: 'a z'
}
raw: 'special-1=a z'
raw: 'special-1=a z'
},
SetCookieTestCase{
cookie: &http.Cookie{
name: 'special-2'
value: ' z'
}
raw: 'special-2=" z"'
raw: 'special-2=" z"'
},
SetCookieTestCase{
cookie: &http.Cookie{
name: 'special-3'
value: 'a '
}
raw: 'special-3="a "'
raw: 'special-3="a "'
},
SetCookieTestCase{
cookie: &http.Cookie{
name: 'special-4'
value: ' '
}
raw: 'special-4=" "'
raw: 'special-4=" "'
},
SetCookieTestCase{
cookie: &http.Cookie{
name: 'special-5'
value: 'a,z'
}
raw: 'special-5=a,z'
raw: 'special-5=a,z'
},
SetCookieTestCase{
cookie: &http.Cookie{
name: 'special-6'
value: ',z'
}
raw: 'special-6=",z"'
raw: 'special-6=",z"'
},
SetCookieTestCase{
cookie: &http.Cookie{
name: 'special-7'
value: 'a,'
}
raw: 'special-7="a,"'
raw: 'special-7="a,"'
},
SetCookieTestCase{
cookie: &http.Cookie{
name: 'special-8'
value: ','
}
raw: 'special-8=","'
raw: 'special-8=","'
},
SetCookieTestCase{
cookie: &http.Cookie{
name: 'empty-value'
value: ''
}
raw: 'empty-value='
raw: 'empty-value='
},
SetCookieTestCase{
cookie: &http.Cookie{
name: ''
}
raw: ''
raw: ''
},
SetCookieTestCase{
cookie: &http.Cookie{
name: '\t'
}
raw: ''
raw: ''
},
SetCookieTestCase{
cookie: &http.Cookie{
name: '\r'
}
raw: ''
raw: ''
},
SetCookieTestCase{
cookie: &http.Cookie{
name: 'a\nb'
value: 'v'
}
raw: ''
raw: ''
},
SetCookieTestCase{
cookie: &http.Cookie{
name: 'a\nb'
value: 'v'
}
raw: ''
raw: ''
},
SetCookieTestCase{
cookie: &http.Cookie{
name: 'a\rb'
value: 'v'
}
raw: ''
raw: ''
},
]
const add_cookies_tests = [
@ -235,7 +235,7 @@ const add_cookies_tests = [
name: 'cookie-1'
value: 'v1'
}]
raw: 'cookie-1=v1'
raw: 'cookie-1=v1'
},
AddCookieTestCase{
cookie: [&http.Cookie{
@ -249,7 +249,7 @@ const add_cookies_tests = [
name: 'cookie-3'
value: 'v3'
}]
raw: 'cookie-1=v1; cookie-2=v2; cookie-3=v3'
raw: 'cookie-1=v1; cookie-2=v2; cookie-3=v3'
},
]

View file

@ -33,7 +33,7 @@ pub fn serve(params StaticServeParams) {
mut nparams := params
nparams.folder = os.norm_path(os.real_path(params.folder))
mut server := &http.Server{
handler: StaticHttpHandler{
handler: StaticHttpHandler{
params: nparams
}
addr: params.on

View file

@ -1774,9 +1774,9 @@ const db = {
charset: ''
}
'application/octet-stream': MimeType{
source: 'iana'
extensions: ['bin', 'dms', 'lrf', 'mar', 'so', 'dist', 'distz', 'pkg', 'bpk', 'dump', 'elc',
'deploy', 'exe', 'dll', 'deb', 'dmg', 'iso', 'img', 'msi', 'msp', 'msm', 'buffer']
source: 'iana'
extensions: ['bin', 'dms', 'lrf', 'mar', 'so', 'dist', 'distz', 'pkg', 'bpk', 'dump',
'elc', 'deploy', 'exe', 'dll', 'deb', 'dmg', 'iso', 'img', 'msi', 'msp', 'msm', 'buffer']
compressible: false
charset: ''
}

View file

@ -155,7 +155,7 @@ fn test_server_custom_handler() {
progress_calls.chunks << chunk.clone()
progress_calls.reads << read_so_far
}
on_finish: fn (req &http.Request, final_size u64) ! {
on_finish: fn (req &http.Request, final_size u64) ! {
mut progress_calls := unsafe { &ProgressCalls(req.user_ptr) }
eprintln('>>>>>>>> on_finish, req.url: ${req.url}, final_size: ${final_size}')
progress_calls.finished_was_called = true

View file

@ -92,13 +92,13 @@ pub:
pub fn new_client(address string, opt ClientOpt) !&Client {
uri := parse_uri(address)!
return &Client{
conn: unsafe { nil }
is_server: false
ssl_conn: ssl.new_ssl_conn()!
is_ssl: address.starts_with('wss')
logger: opt.logger
uri: uri
client_state: ClientState{
conn: unsafe { nil }
is_server: false
ssl_conn: ssl.new_ssl_conn()!
is_ssl: address.starts_with('wss')
logger: opt.logger
uri: uri
client_state: ClientState{
state: .closed
}
id: rand.uuid_v4()

View file

@ -32,13 +32,13 @@ fn test_field_after_fkeys() {
}!
person := Person{
age: 21
brothers: [Brother{
age: 21
brothers: [Brother{
name: 'aaa'
}, Brother{
name: 'bbb'
}]
sisters: [Sister{
sisters: [Sister{
name: 'ccc'
}, Sister{
name: 'ddd'

View file

@ -305,7 +305,7 @@ fn test_orm_insert_with_multiple_child_elements() {
name: 'Steve'
},
]
notes: [
notes: [
Note{
text: 'First note'
},

View file

@ -88,13 +88,13 @@ pub fn (st Stat) get_filetype() FileType {
// in owner/group/others format
pub fn (st Stat) get_mode() FileMode {
return FileMode{
typ: st.get_filetype()
owner: FilePermission{
typ: st.get_filetype()
owner: FilePermission{
read: (st.mode & u32(C.S_IRUSR)) != 0
write: (st.mode & u32(C.S_IWUSR)) != 0
execute: (st.mode & u32(C.S_IXUSR)) != 0
}
group: FilePermission{
group: FilePermission{
read: (st.mode & u32(C.S_IRGRP)) != 0
write: (st.mode & u32(C.S_IWGRP)) != 0
execute: (st.mode & u32(C.S_IXGRP)) != 0

View file

@ -51,13 +51,13 @@ pub fn (st Stat) get_filetype() FileType {
// in owner/group/others format, however, they will all be the same for Windows
pub fn (st Stat) get_mode() FileMode {
return FileMode{
typ: st.get_filetype()
owner: FilePermission{
typ: st.get_filetype()
owner: FilePermission{
read: (st.mode & u32(C.S_IREAD)) != 0
write: (st.mode & u32(C.S_IWRITE)) != 0
execute: (st.mode & u32(C.S_IEXEC)) != 0
}
group: FilePermission{
group: FilePermission{
read: (st.mode & u32(C.S_IREAD)) != 0
write: (st.mode & u32(C.S_IWRITE)) != 0
execute: (st.mode & u32(C.S_IEXEC)) != 0

View file

@ -382,5 +382,5 @@ pub enum UniformLayout as u32 {
uniformlayout_native // default: layout depends on currently active backend
uniformlayout_std140 // std140: memory layout according to std140
_num
_force_u32 = 0x7FFFFFFF
_force_u32 = 0x7FFFFFFF
}

View file

@ -338,6 +338,7 @@ pub:
i int
has_default_expr bool
has_prev_newline bool
has_break_line bool
attrs []Attr
is_pub bool
default_val string
@ -468,6 +469,7 @@ pub:
end_comments []Comment
next_comments []Comment
has_prev_newline bool
has_break_line bool
pub mut:
expr Expr // `val1`
name string // 'field1'
@ -573,6 +575,7 @@ pub:
method_idx int
rec_mut bool // is receiver mutable
has_prev_newline bool
has_break_line bool
rec_share ShareType
language Language // V, C, JS
file_mode Language // whether *the file*, where a function was a '.c.v', '.js.v' etc.
@ -1381,6 +1384,7 @@ pub:
next_comments []Comment // comments between current EnumField and next EnumField
has_expr bool // true, when .expr has a value
has_prev_newline bool // empty newline before Enumfield
has_break_line bool
attrs []Attr
pub mut:
expr Expr // the value of current EnumField; 123 in `ename = 123`

View file

@ -98,7 +98,7 @@ pub fn new_table() &Table {
global_scope: &Scope{
parent: unsafe { nil }
}
cur_fn: unsafe { nil }
cur_fn: unsafe { nil }
}
t.register_builtin_type_symbols()
t.is_fmt = true

View file

@ -731,13 +731,13 @@ or use an explicit `unsafe{ a[..] }`, if you do not want a copy of the slice.',
}
node = ast.AssignStmt{
op: .assign
pos: node.pos
end_comments: node.end_comments
left: node.left
right: [
op: .assign
pos: node.pos
end_comments: node.end_comments
left: node.left
right: [
ast.Expr(ast.InfixExpr{
left: ast.CastExpr{
left: ast.CastExpr{
expr: node.left[0]
typ: modified_left_type
typname: c.table.type_str(modified_left_type)

View file

@ -146,9 +146,9 @@ pub fn new_checker(table &ast.Table, pref_ &pref.Preferences) &Checker {
timers_should_print = true
}
mut checker := &Checker{
table: table
pref: pref_
timers: util.new_timers(
table: table
pref: pref_
timers: util.new_timers(
should_print: timers_should_print
label: 'checker'
)

View file

@ -696,7 +696,7 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
}
node = ast.InfixExpr{
left: ast.CastExpr{
left: ast.CastExpr{
expr: node.left
typ: modified_left_type
typname: c.table.type_str(modified_left_type)

View file

@ -107,7 +107,7 @@ pub fn (mut c Checker) lambda_expr(mut node ast.LambdaExpr, exp_typ ast.Type) as
scope: node.scope.parent
generic_names: generic_names
}
typ: typ
typ: typ
}
if node.func.decl.generic_names.len > 0 {
c.table.register_fn_generic_types(node.func.decl.fkey())
@ -141,7 +141,7 @@ pub fn (mut c Checker) lambda_expr_fix_type_of_param(mut node ast.LambdaExpr, mu
pub fn (mut c Checker) support_lambda_expr_in_sort(param_type ast.Type, return_type ast.Type, mut expr ast.LambdaExpr) {
is_auto_rec := param_type.is_ptr()
mut expected_fn := ast.Fn{
params: [
params: [
ast.Param{
name: 'zza'
typ: param_type
@ -162,7 +162,7 @@ pub fn (mut c Checker) support_lambda_expr_in_sort(param_type ast.Type, return_t
pub fn (mut c Checker) support_lambda_expr_one_param(param_type ast.Type, return_type ast.Type, mut expr ast.LambdaExpr) {
mut expected_fn := ast.Fn{
params: [
params: [
ast.Param{
name: 'xx'
typ: param_type

View file

@ -72,12 +72,12 @@ fn (mut c Checker) sql_expr(mut node ast.SqlExpr) ast.Type {
foreign_typ := c.get_field_foreign_table_type(field)
mut subquery_expr := ast.SqlExpr{
pos: node.pos
has_where: true
where_expr: ast.None{}
typ: field.typ.clear_flag(.option).set_flag(.result)
db_expr: node.db_expr
table_expr: ast.TypeNode{
pos: node.pos
has_where: true
where_expr: ast.None{}
typ: field.typ.clear_flag(.option).set_flag(.result)
db_expr: node.db_expr
table_expr: ast.TypeNode{
pos: node.table_expr.pos
typ: foreign_typ
}
@ -89,9 +89,9 @@ fn (mut c Checker) sql_expr(mut node ast.SqlExpr) ast.Type {
c.inside_sql = tmp_inside_sql
subquery_expr.where_expr = ast.InfixExpr{
op: .eq
pos: subquery_expr.pos
left: ast.Ident{
op: .eq
pos: subquery_expr.pos
left: ast.Ident{
language: .v
tok_kind: .eq
scope: c.fn_scope
@ -102,7 +102,7 @@ fn (mut c Checker) sql_expr(mut node ast.SqlExpr) ast.Type {
kind: .unresolved
info: ast.IdentVar{}
}
right: ast.Ident{
right: ast.Ident{
language: .c
mod: 'main'
tok_kind: .eq
@ -299,9 +299,9 @@ fn (mut c Checker) sql_stmt_line(mut node ast.SqlStmtLine) ast.Type {
foreign_typ := c.get_field_foreign_table_type(field)
mut subquery_expr := ast.SqlStmtLine{
pos: node.pos
kind: node.kind
table_expr: ast.TypeNode{
pos: node.pos
kind: node.kind
table_expr: ast.TypeNode{
pos: node.table_expr.pos
typ: foreign_typ
}

View file

@ -99,10 +99,10 @@ pub fn (sk SymbolKind) str() string {
@[minify]
pub struct Doc {
pub mut:
prefs &pref.Preferences = new_vdoc_preferences()
base_path string
table &ast.Table = ast.new_table()
checker checker.Checker = checker.Checker{
prefs &pref.Preferences = new_vdoc_preferences()
base_path string
table &ast.Table = ast.new_table()
checker checker.Checker = checker.Checker{
table: unsafe { nil }
pref: unsafe { nil }
}

View file

@ -13,6 +13,7 @@ mut:
struct AlignConfig {
pub:
ignore_newline bool // ignore newline or comment
use_break_line bool
use_threshold bool
threshold int = 25
}
@ -38,13 +39,14 @@ fn (mut fa FieldAlign) add_new_info(len int, line int) {
}
@[direct_array_access]
fn (mut fa FieldAlign) add_info(len int, line int) {
fn (mut fa FieldAlign) add_info(len int, line int, has_break_line bool) {
if fa.infos.len == 0 {
fa.add_new_info(len, line)
return
}
i := fa.infos.len - 1
if !fa.cfg.ignore_newline && line - fa.infos[i].line_nr > 1 {
if !fa.cfg.ignore_newline && ((fa.cfg.use_break_line && has_break_line)
|| (!fa.cfg.use_break_line && line - fa.infos[i].line_nr > 1)) {
fa.add_new_info(len, line)
return
}

View file

@ -1039,28 +1039,28 @@ pub fn (mut f Fmt) enum_decl(node ast.EnumDecl) {
f.writeln('enum ${name} {')
f.comments(node.comments, same_line: true, level: .indent)
mut value_align := new_field_align()
mut attr_align := new_field_align()
mut comment_align := new_field_align()
mut value_align := new_field_align(use_break_line: true)
mut attr_align := new_field_align(use_threshold: true)
mut comment_align := new_field_align(use_threshold: true)
for field in node.fields {
if field.has_expr {
value_align.add_info(field.name.len, field.pos.line_nr)
value_align.add_info(field.name.len, field.pos.line_nr, field.has_break_line)
}
attrs_len := inline_attrs_len(field.attrs)
if field.attrs.len > 0 {
if field.has_expr {
attr_align.add_info(field.expr.str().len + 2, field.pos.line_nr)
attr_align.add_info(field.expr.str().len + 2, field.pos.line_nr, field.has_break_line)
} else {
attr_align.add_info(field.name.len, field.pos.line_nr)
attr_align.add_info(field.name.len, field.pos.line_nr, field.has_break_line)
}
}
if field.comments.len > 0 {
if field.attrs.len > 0 {
comment_align.add_info(attrs_len, field.pos.line_nr)
comment_align.add_info(attrs_len, field.pos.line_nr, field.has_break_line)
} else if field.has_expr {
comment_align.add_info(field.expr.str().len + 2, field.pos.line_nr)
comment_align.add_info(field.expr.str().len + 2, field.pos.line_nr, field.has_break_line)
} else {
comment_align.add_info(field.name.len, field.pos.line_nr)
comment_align.add_info(field.name.len, field.pos.line_nr, field.has_break_line)
}
}
}
@ -1397,7 +1397,7 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) {
}
}
mut type_align := new_field_align()
mut type_align := new_field_align(use_break_line: true)
mut comment_align := new_field_align(use_threshold: true)
mut default_expr_align := new_field_align(use_threshold: true)
mut attr_align := new_field_align(use_threshold: true)
@ -1412,7 +1412,7 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) {
end_comments := method.comments.filter(it.pos.pos > method.pos.pos)
if end_comments.len > 0 {
method_str := f.table.stringify_fn_decl(&method, f.cur_mod, f.mod2alias, false).all_after_first('fn ')
method_comment_align.add_info(method_str.len, method.pos.line_nr)
method_comment_align.add_info(method_str.len, method.pos.line_nr, method.has_break_line)
}
}
@ -1464,12 +1464,12 @@ pub fn (mut f Fmt) calculate_alignment(fields []ast.StructField, mut type_align
field_types << ft
attrs_len := inline_attrs_len(field.attrs)
end_pos := field.pos.pos + field.pos.len
type_align.add_info(field.name.len, field.pos.line_nr)
type_align.add_info(field.name.len, field.pos.line_nr, field.has_break_line)
if field.has_default_expr {
default_expr_align.add_info(ft.len, field.pos.line_nr)
default_expr_align.add_info(ft.len, field.pos.line_nr, field.has_break_line)
}
if field.attrs.len > 0 {
attr_align.add_info(ft.len, field.pos.line_nr)
attr_align.add_info(ft.len, field.pos.line_nr, field.has_break_line)
}
for comment in field.comments {
if comment.pos.pos >= end_pos {
@ -1478,7 +1478,7 @@ pub fn (mut f Fmt) calculate_alignment(fields []ast.StructField, mut type_align
if prev_state != AlignState.has_attributes {
comment_align.add_new_info(attrs_len, comment.pos.line_nr)
} else {
comment_align.add_info(attrs_len, comment.pos.line_nr)
comment_align.add_info(attrs_len, comment.pos.line_nr, field.has_break_line)
}
prev_state = AlignState.has_attributes
} else if field.has_default_expr {
@ -1486,14 +1486,15 @@ pub fn (mut f Fmt) calculate_alignment(fields []ast.StructField, mut type_align
comment_align.add_new_info(field.default_expr.str().len + 2,
comment.pos.line_nr)
} else {
comment_align.add_info(field.default_expr.str().len + 2, comment.pos.line_nr)
comment_align.add_info(field.default_expr.str().len + 2, comment.pos.line_nr,
field.has_break_line)
}
prev_state = AlignState.has_default_expression
} else {
if prev_state != AlignState.has_everything {
comment_align.add_new_info(ft.len, comment.pos.line_nr)
} else {
comment_align.add_info(ft.len, comment.pos.line_nr)
comment_align.add_info(ft.len, comment.pos.line_nr, field.has_break_line)
}
prev_state = AlignState.has_everything
}

View file

@ -26,7 +26,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl, is_anon bool) {
f.writeln(' {}')
return
}
mut type_align := new_field_align()
mut type_align := new_field_align(use_break_line: true)
mut default_expr_align := new_field_align(use_threshold: true)
mut attr_align := new_field_align(use_threshold: true)
mut comment_align := new_field_align(use_threshold: true)
@ -278,12 +278,13 @@ pub fn (mut f Fmt) struct_init(node ast.StructInit) {
}
f.comments(node.update_expr_comments, same_line: true, has_nl: true, level: .keep)
}
mut value_align := new_field_align()
mut value_align := new_field_align(use_break_line: true)
mut comment_align := new_field_align(use_threshold: true)
for init_field in node.init_fields {
value_align.add_info(init_field.name.len, init_field.pos.line_nr)
value_align.add_info(init_field.name.len, init_field.pos.line_nr, init_field.has_break_line)
if init_field.end_comments.len > 0 {
comment_align.add_info(init_field.expr.str().len, init_field.pos.line_nr)
comment_align.add_info(init_field.expr.str().len, init_field.pos.line_nr,
init_field.has_break_line)
}
}
for i, init_field in node.init_fields {

View file

@ -2,7 +2,7 @@ import net.http
const write_set_cookie_tests = [
ReadSetCookiesTestCase{
header: {
header: {
'Set-Cookie': ['special-7=","']
}
cookies: [&http.Cookie{

View file

@ -2,7 +2,7 @@ enum Info {
aa = 1 // aa
bbb // bbb
cccc = 5 /* cccc
cccc = 5 /* cccc
--- cccc
*/
ddddd = 10 // ddddd

View file

@ -2,7 +2,7 @@ enum Info {
aa = 1 // aa
bbb // bbb
cccc = 5 /* cccc
cccc = 5 /* cccc
--- cccc
*/
ddddd = 10 // ddddd

View file

@ -41,7 +41,7 @@ struct SomeStruct {
mut:
// 2
// 3
somefield int /*
somefield int /*
9
10
*/

View file

@ -332,10 +332,10 @@ pub fn gen(files []&ast.File, mut table ast.Table, pref_ &pref.Preferences) (str
is_cc_msvc: pref_.ccompiler == 'msvc'
use_segfault_handler: !('no_segfault_handler' in pref_.compile_defines
|| pref_.os in [.wasm32, .wasm32_emscripten])
static_modifier: if pref_.parallel_cc { 'static' } else { '' }
has_reflection: 'v.reflection' in table.modules
has_debugger: 'v.debug' in table.modules
reflection_strings: &reflection_strings
static_modifier: if pref_.parallel_cc { 'static' } else { '' }
has_reflection: 'v.reflection' in table.modules
has_debugger: 'v.debug' in table.modules
reflection_strings: &reflection_strings
}
global_g.comptime = &comptime.ComptimeInfo{
@ -2440,7 +2440,7 @@ fn (mut g Gen) get_sumtype_casting_fn(got_ ast.Type, exp_ ast.Type) string {
} else {
got_sym.idx
}
exp: if exp_.has_flag(.option) {
exp: if exp_.has_flag(.option) {
new_exp := ast.idx_to_type(exp).set_flag(.option)
new_exp
} else {

View file

@ -7,7 +7,7 @@ fn test_simple() {
mlist := [
MappingInput{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -18,7 +18,7 @@ fn test_simple() {
}
},
MappingInput{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 2
gen_column: 0
}
@ -29,7 +29,7 @@ fn test_simple() {
}
},
MappingInput{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 2
gen_column: 2
}
@ -40,7 +40,7 @@ fn test_simple() {
}
},
MappingInput{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 2
gen_column: 9
}
@ -51,7 +51,7 @@ fn test_simple() {
}
},
MappingInput{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 2
gen_column: 10
}
@ -62,7 +62,7 @@ fn test_simple() {
}
},
MappingInput{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 2
gen_column: 13
}
@ -73,7 +73,7 @@ fn test_simple() {
}
},
MappingInput{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 2
gen_column: 14
}
@ -84,7 +84,7 @@ fn test_simple() {
}
},
MappingInput{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 2
gen_column: 27
}
@ -95,7 +95,7 @@ fn test_simple() {
}
},
MappingInput{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 2
gen_column: 28
}
@ -106,7 +106,7 @@ fn test_simple() {
}
},
MappingInput{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 2
gen_column: 29
}
@ -117,7 +117,7 @@ fn test_simple() {
}
},
MappingInput{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 3
gen_column: 0
}

View file

@ -2,7 +2,7 @@ module sourcemap
fn test_cmp_eq() {
a := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -15,7 +15,7 @@ fn test_cmp_eq() {
}
b := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -32,7 +32,7 @@ fn test_cmp_eq() {
fn test_cmp_name() {
a := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -45,7 +45,7 @@ fn test_cmp_name() {
}
b := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -62,7 +62,7 @@ fn test_cmp_name() {
fn test_cmp_name_empty() {
a := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -75,7 +75,7 @@ fn test_cmp_name_empty() {
}
b := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -92,7 +92,7 @@ fn test_cmp_name_empty() {
fn test_cmp_name_empty_empty() {
a := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -105,7 +105,7 @@ fn test_cmp_name_empty_empty() {
}
b := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -122,7 +122,7 @@ fn test_cmp_name_empty_empty() {
fn test_cmp_source_position_empty_eq() {
a := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -132,7 +132,7 @@ fn test_cmp_source_position_empty_eq() {
}
b := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -146,7 +146,7 @@ fn test_cmp_source_position_empty_eq() {
fn test_cmp_source_position_empty_diff() {
a := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -159,7 +159,7 @@ fn test_cmp_source_position_empty_diff() {
}
b := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -173,7 +173,7 @@ fn test_cmp_source_position_empty_diff() {
fn test_cmp_source_position_column_diff() {
a := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -186,7 +186,7 @@ fn test_cmp_source_position_column_diff() {
}
b := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -203,7 +203,7 @@ fn test_cmp_source_position_column_diff() {
fn test_cmp_source_position_line_diff() {
a := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -216,7 +216,7 @@ fn test_cmp_source_position_line_diff() {
}
b := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -233,7 +233,7 @@ fn test_cmp_source_position_line_diff() {
fn test_cmp_sources() {
a := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -246,7 +246,7 @@ fn test_cmp_sources() {
}
b := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -263,7 +263,7 @@ fn test_cmp_sources() {
fn test_cmp_gen_column() {
a := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -276,7 +276,7 @@ fn test_cmp_gen_column() {
}
b := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 99
}
@ -293,7 +293,7 @@ fn test_cmp_gen_column() {
fn test_cmp_gen_line() {
a := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 0
}
@ -306,7 +306,7 @@ fn test_cmp_gen_line() {
}
b := Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: 1
gen_column: 99
}

View file

@ -41,7 +41,7 @@ mut:
fn new_mappings() Mappings {
return Mappings{
last: Mapping{
last: Mapping{
GenPosition: GenPosition{
gen_column: 0
gen_line: 0
@ -59,7 +59,7 @@ fn (mut m Mappings) add_mapping(gen_line u32, gen_column u32, sources_ind u32, s
m.is_sorted = false
}
m.values << Mapping{
GenPosition: GenPosition{
GenPosition: GenPosition{
gen_line: gen_line
gen_column: gen_column
}

View file

@ -27,19 +27,19 @@ pub fn (mut g Gen) init_builtins() {
// used to keep executable size small and the bytecode distraction-free
.int_to_string: BuiltinFn{
// 32-bit signed integer to string conversion
body: fn (builtin BuiltinFn, mut g Gen) {
body: fn (builtin BuiltinFn, mut g Gen) {
g.code_gen.convert_int_to_string(builtin.arg_regs[0], builtin.arg_regs[1])
}
arg_regs: [Amd64Register.rcx, Amd64Register.rdi]
}
.bool_to_string: BuiltinFn{
body: fn (builtin BuiltinFn, mut g Gen) {
body: fn (builtin BuiltinFn, mut g Gen) {
g.code_gen.convert_bool_to_string(builtin.arg_regs[0])
}
arg_regs: [Amd64Register.rax]
}
.reverse_string: BuiltinFn{
body: fn (builtin BuiltinFn, mut g Gen) {
body: fn (builtin BuiltinFn, mut g Gen) {
g.code_gen.reverse_string(builtin.arg_regs[0])
}
arg_regs: [Amd64Register.rdi]

View file

@ -453,7 +453,7 @@ fn (mut g Gen) create_section(name string, typ i32, link i32, info i32, addralig
addralign: addralign
entsize: entsize
}
data: data
data: data
}
}

View file

@ -338,8 +338,8 @@ pub fn gen(files []&ast.File, mut table ast.Table, out_name string, pref_ &pref.
eprintln('No available backend for this configuration. Use `-a arm64` or `-a amd64`.')
exit(1)
}
structs: []Struct{len: table.type_symbols.len}
eval: eval.new_eval(table, pref_)
structs: []Struct{len: table.type_symbols.len}
eval: eval.new_eval(table, pref_)
}
g.code_gen.g = g

View file

@ -244,8 +244,8 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
embed_file: ast.EmbeddedFile{
compression_type: embed_compression_type
}
args: [arg]
pos: start_pos.extend(p.prev_tok.pos())
args: [arg]
pos: start_pos.extend(p.prev_tok.pos())
}
}
// Compile vweb html template to V code, parse that V code and embed the resulting V function

View file

@ -462,7 +462,7 @@ fn (mut p Parser) check_expr(precedence int) !ast.Expr {
kind: or_kind
pos: or_pos
}
scope: p.scope
scope: p.scope
}
}
return node

View file

@ -109,8 +109,8 @@ fn (mut p Parser) call_expr(language ast.Language, mod string) ast.CallExpr {
kind: or_kind
pos: or_pos
}
scope: p.scope
comments: comments
scope: p.scope
comments: comments
}
}
@ -654,7 +654,7 @@ run them via `v file.v` instead',
is_conditional: conditional_ctdefine_idx != ast.invalid_type_idx
ctdefine_idx: conditional_ctdefine_idx
//
receiver: ast.StructField{
receiver: ast.StructField{
name: rec.name
typ: rec.typ
}
@ -870,7 +870,7 @@ fn (mut p Parser) anon_fn() ast.AnonFn {
p.inside_defer = old_inside_defer
// name := p.table.get_type_name(typ)
return ast.AnonFn{
decl: ast.FnDecl{
decl: ast.FnDecl{
name: name
short_name: ''
mod: p.mod

View file

@ -216,9 +216,9 @@ fn (mut p Parser) parse_sql_stmt_line() ast.SqlStmtLine {
typ := p.parse_type()
typ_pos := p.tok.pos()
return ast.SqlStmtLine{
kind: kind
pos: pos.extend(p.prev_tok.pos())
table_expr: ast.TypeNode{
kind: kind
pos: pos.extend(p.prev_tok.pos())
table_expr: ast.TypeNode{
typ: typ
pos: typ_pos
}
@ -235,9 +235,9 @@ fn (mut p Parser) parse_sql_stmt_line() ast.SqlStmtLine {
typ := p.parse_type()
typ_pos := p.tok.pos()
return ast.SqlStmtLine{
kind: kind
pos: pos.extend(p.prev_tok.pos())
table_expr: ast.TypeNode{
kind: kind
pos: pos.extend(p.prev_tok.pos())
table_expr: ast.TypeNode{
typ: typ
pos: typ_pos
}
@ -314,7 +314,7 @@ fn (mut p Parser) parse_sql_stmt_line() ast.SqlStmtLine {
}
}
return ast.SqlStmtLine{
table_expr: ast.TypeNode{
table_expr: ast.TypeNode{
typ: table_type
pos: table_pos
}

View file

@ -166,10 +166,10 @@ pub fn parse_text(text string, path string, mut table ast.Table, comments_mode s
eprintln('> ${@MOD}.${@FN} comments_mode: ${comments_mode:-20} | path: ${path:-20} | text: ${text}')
}
mut p := Parser{
scanner: scanner.new_scanner(text, comments_mode, pref_)
table: table
pref: pref_
scope: &ast.Scope{
scanner: scanner.new_scanner(text, comments_mode, pref_)
table: table
pref: pref_
scope: &ast.Scope{
start_pos: 0
parent: table.global_scope
}
@ -246,10 +246,10 @@ pub fn parse_file(path string, mut table ast.Table, comments_mode scanner.Commen
eprintln('> ${@MOD}.${@FN} comments_mode: ${comments_mode:-20} | path: ${path}')
}
mut p := Parser{
scanner: scanner.new_scanner_file(path, comments_mode, pref_) or { panic(err) }
table: table
pref: pref_
scope: &ast.Scope{
scanner: scanner.new_scanner_file(path, comments_mode, pref_) or { panic(err) }
table: table
pref: pref_
scope: &ast.Scope{
start_pos: 0
parent: table.global_scope
}
@ -523,6 +523,12 @@ fn (p &Parser) has_prev_newline() bool {
return false
}
fn (p &Parser) has_prev_line_comment_or_label() bool {
return p.prev_tok.kind == .colon || (p.prev_tok.kind == .comment
&& p.tok.line_nr - p.prev_tok.line_nr == 1
&& p.prev_tok.line_nr - p.peek_token(-2).line_nr > 0)
}
fn (p &Parser) is_array_type() bool {
mut i := 1
mut tok := p.tok
@ -2244,7 +2250,7 @@ fn (mut p Parser) parse_multi_expr(is_top_level bool) ast.Stmt {
vals: left
pos: tok.pos()
}
pos: pos
pos: pos
}
}
@ -2327,7 +2333,7 @@ fn (mut p Parser) ident(language ast.Language) ast.Ident {
is_volatile: false
is_option: is_option
}
scope: p.scope
scope: p.scope
}
}
is_following_concrete_types := p.is_following_concrete_types()
@ -2368,16 +2374,16 @@ fn (mut p Parser) ident(language ast.Language) ast.Ident {
}
}
return ast.Ident{
tok_kind: p.tok.kind
kind: .unresolved
name: name
comptime: p.comptime_if_cond
language: language
mod: p.mod
pos: pos
is_mut: is_mut
mut_pos: mut_pos
info: ast.IdentVar{
tok_kind: p.tok.kind
kind: .unresolved
name: name
comptime: p.comptime_if_cond
language: language
mod: p.mod
pos: pos
is_mut: is_mut
mut_pos: mut_pos
info: ast.IdentVar{
typ: typ
is_mut: is_mut
is_static: is_static
@ -2385,8 +2391,8 @@ fn (mut p Parser) ident(language ast.Language) ast.Ident {
is_option: or_kind != ast.OrKind.absent
share: ast.sharetype_from_flags(is_shared, is_atomic)
}
scope: p.scope
or_expr: ast.OrExpr{
scope: p.scope
or_expr: ast.OrExpr{
kind: or_kind
stmts: or_stmts
pos: or_pos
@ -2911,7 +2917,7 @@ fn (mut p Parser) name_expr() ast.Expr {
}
pos.extend(p.tok.pos())
return ast.SelectorExpr{
expr: ast.Ident{
expr: ast.Ident{
name: name
scope: p.scope
}
@ -2943,10 +2949,10 @@ fn (mut p Parser) name_expr() ast.Expr {
field_name := p.check_name()
pos.extend(p.tok.pos())
return ast.Ident{
name: p.prepend_mod(typ_name) + '__static__' + field_name
mod: p.mod
kind: .function
info: ast.IdentFn{
name: p.prepend_mod(typ_name) + '__static__' + field_name
mod: p.mod
kind: .function
info: ast.IdentFn{
typ: fn_type
}
pos: pos
@ -3102,16 +3108,16 @@ fn (mut p Parser) index_expr(left ast.Expr, is_gated bool) ast.IndexExpr {
if p.tok.kind == .key_orelse {
or_stmts_high, or_pos_high = p.or_block(.no_err_var)
return ast.IndexExpr{
left: left
pos: pos_high
index: ast.RangeExpr{
left: left
pos: pos_high
index: ast.RangeExpr{
low: ast.empty_expr
high: high
has_high: has_high
pos: pos_high
is_gated: is_gated
}
or_expr: ast.OrExpr{
or_expr: ast.OrExpr{
kind: .block
stmts: or_stmts_high
pos: or_pos_high
@ -3131,16 +3137,16 @@ fn (mut p Parser) index_expr(left ast.Expr, is_gated bool) ast.IndexExpr {
}
return ast.IndexExpr{
left: left
pos: pos_high
index: ast.RangeExpr{
left: left
pos: pos_high
index: ast.RangeExpr{
low: ast.empty_expr
high: high
has_high: has_high
pos: pos_high
is_gated: is_gated
}
or_expr: ast.OrExpr{
or_expr: ast.OrExpr{
kind: or_kind_high
stmts: or_stmts_high
pos: or_pos_high
@ -3170,9 +3176,9 @@ fn (mut p Parser) index_expr(left ast.Expr, is_gated bool) ast.IndexExpr {
if p.tok.kind == .key_orelse {
or_stmts_low, or_pos_low = p.or_block(.no_err_var)
return ast.IndexExpr{
left: left
pos: pos_low
index: ast.RangeExpr{
left: left
pos: pos_low
index: ast.RangeExpr{
low: expr
high: high
has_high: has_high
@ -3180,7 +3186,7 @@ fn (mut p Parser) index_expr(left ast.Expr, is_gated bool) ast.IndexExpr {
pos: pos_low
is_gated: is_gated
}
or_expr: ast.OrExpr{
or_expr: ast.OrExpr{
kind: .block
stmts: or_stmts_low
pos: or_pos_low
@ -3200,9 +3206,9 @@ fn (mut p Parser) index_expr(left ast.Expr, is_gated bool) ast.IndexExpr {
}
return ast.IndexExpr{
left: left
pos: pos_low
index: ast.RangeExpr{
left: left
pos: pos_low
index: ast.RangeExpr{
low: expr
high: high
has_high: has_high
@ -3210,7 +3216,7 @@ fn (mut p Parser) index_expr(left ast.Expr, is_gated bool) ast.IndexExpr {
pos: pos_low
is_gated: is_gated
}
or_expr: ast.OrExpr{
or_expr: ast.OrExpr{
kind: or_kind_low
stmts: or_stmts_low
pos: or_pos_low
@ -3229,10 +3235,10 @@ fn (mut p Parser) index_expr(left ast.Expr, is_gated bool) ast.IndexExpr {
if p.tok.kind == .key_orelse {
or_stmts, or_pos = p.or_block(.no_err_var)
return ast.IndexExpr{
left: left
index: expr
pos: pos
or_expr: ast.OrExpr{
left: left
index: expr
pos: pos
or_expr: ast.OrExpr{
kind: .block
stmts: or_stmts
pos: or_pos
@ -3251,10 +3257,10 @@ fn (mut p Parser) index_expr(left ast.Expr, is_gated bool) ast.IndexExpr {
}
}
return ast.IndexExpr{
left: left
index: expr
pos: pos
or_expr: ast.OrExpr{
left: left
index: expr
pos: pos
or_expr: ast.OrExpr{
kind: or_kind
stmts: or_stmts
pos: or_pos
@ -3342,8 +3348,8 @@ fn (mut p Parser) dot_expr(left ast.Expr) ast.Expr {
kind: or_kind
pos: or_pos
}
scope: p.scope
comments: comments
scope: p.scope
comments: comments
}
return mcall_expr
}
@ -4171,6 +4177,7 @@ fn (mut p Parser) enum_decl() ast.EnumDecl {
pre_comments := p.eat_comments()
pos := p.tok.pos()
has_prev_newline := p.has_prev_newline()
has_break_line := has_prev_newline || p.has_prev_line_comment_or_label()
val := p.check_name()
vals << val
mut expr := ast.empty_expr
@ -4198,6 +4205,7 @@ fn (mut p Parser) enum_decl() ast.EnumDecl {
expr: expr
has_expr: has_expr
has_prev_newline: has_prev_newline
has_break_line: has_break_line
pre_comments: pre_comments
comments: comments
next_comments: next_comments
@ -4293,11 +4301,11 @@ fn (mut p Parser) enum_decl() ast.EnumDecl {
}
idx := p.table.register_sym(ast.TypeSymbol{
kind: .enum_
name: name
cname: util.no_dots(name)
mod: p.mod
info: ast.Enum{
kind: .enum_
name: name
cname: util.no_dots(name)
mod: p.mod
info: ast.Enum{
vals: vals
is_flag: is_flag
is_multi_allowed: is_multi_allowed
@ -4408,11 +4416,11 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
variant_types := sum_variants.map(it.typ)
prepend_mod_name := p.prepend_mod(name)
typ := p.table.register_sym(ast.TypeSymbol{
kind: .sum_type
name: prepend_mod_name
cname: util.no_dots(prepend_mod_name)
mod: p.mod
info: ast.SumType{
kind: .sum_type
name: prepend_mod_name
cname: util.no_dots(prepend_mod_name)
mod: p.mod
info: ast.SumType{
variants: variant_types
is_generic: generic_types.len > 0
generic_types: generic_types
@ -4462,7 +4470,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
parent_type: parent_type
language: parent_language
}
is_pub: is_pub
is_pub: is_pub
})
type_end_pos := p.prev_tok.pos()
if idx in [ast.string_type_idx, ast.rune_type_idx, ast.array_type_idx, ast.map_type_idx] {

View file

@ -193,6 +193,7 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
|| p.peek_tok.kind == .dot) && language == .v && p.peek_tok.kind != .key_fn
is_on_top := ast_fields.len == 0 && !(is_field_pub || is_field_mut || is_field_global)
has_prev_newline := p.has_prev_newline()
has_break_line := has_prev_newline || p.has_prev_line_comment_or_label()
mut field_name := ''
mut typ := ast.no_type
mut type_pos := token.Pos{}
@ -311,6 +312,7 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
default_expr: default_expr
has_default_expr: has_default_expr
has_prev_newline: has_prev_newline
has_break_line: has_break_line
attrs: p.attrs
is_pub: is_embed || is_field_pub
is_mut: is_embed || is_field_mut
@ -369,7 +371,7 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
attrs: attrs
is_anon: is_anon
}
is_pub: is_pub
is_pub: is_pub
}
if p.table.has_deep_child_no_ref(&sym, name) {
p.error_with_pos('invalid recursive struct `${orig_name}`', name_pos)
@ -431,6 +433,7 @@ fn (mut p Parser) struct_init(typ_str string, kind ast.StructInitKind, is_option
mut has_update_expr := false
mut update_expr_pos := token.Pos{}
mut has_prev_newline := false
mut has_break_line := false
for p.tok.kind !in [.rcbr, .rpar, .eof] {
mut field_name := ''
mut expr := ast.empty_expr
@ -457,6 +460,7 @@ fn (mut p Parser) struct_init(typ_str string, kind ast.StructInitKind, is_option
prev_comments = p.eat_comments()
first_field_pos = p.tok.pos()
has_prev_newline = p.has_prev_newline()
has_break_line = has_prev_newline || p.has_prev_line_comment_or_label()
field_name = p.check_name()
p.check(.colon)
expr = p.expr(0)
@ -491,6 +495,7 @@ fn (mut p Parser) struct_init(typ_str string, kind ast.StructInitKind, is_option
next_comments: nline_comments
parent_type: typ
has_prev_newline: has_prev_newline
has_break_line: has_break_line
}
}
}
@ -513,11 +518,11 @@ fn (mut p Parser) struct_init(typ_str string, kind ast.StructInitKind, is_option
} else {
p.prev_tok.pos()
})
no_keys: no_keys
is_short_syntax: kind == .short_syntax
is_anon: kind == .anon
pre_comments: pre_comments
generic_types: struct_init_generic_types
no_keys: no_keys
is_short_syntax: kind == .short_syntax
is_anon: kind == .anon
pre_comments: pre_comments
generic_types: struct_init_generic_types
}
}
@ -563,12 +568,12 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
}
// Declare the type
reg_idx := p.table.register_sym(
is_pub: is_pub
kind: .interface_
name: interface_name
cname: util.no_dots(interface_name)
mod: p.mod
info: ast.Interface{
is_pub: is_pub
kind: .interface_
name: interface_name
cname: util.no_dots(interface_name)
mod: p.mod
info: ast.Interface{
types: []
is_generic: generic_types.len > 0
generic_types: generic_types
@ -665,6 +670,7 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
if p.peek_tok.kind == .lpar {
method_start_pos := p.tok.pos()
has_prev_newline := p.has_prev_newline()
has_break_line := has_prev_newline || p.has_prev_line_comment_or_label()
line_nr := p.tok.line_nr
name := p.check_name()
@ -698,6 +704,7 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
pos: method_start_pos.extend(p.prev_tok.pos())
scope: p.scope
has_prev_newline: has_prev_newline
has_break_line: has_break_line
}
if p.tok.kind.is_start_of_type() && p.tok.line_nr == line_nr {
method.return_type_pos = p.tok.pos()
@ -726,6 +733,7 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
// interface fields
field_pos := p.tok.pos()
has_prev_newline := p.has_prev_newline()
has_break_line := has_prev_newline || p.has_prev_line_comment_or_label()
field_name := p.check_name()
mut type_pos := p.tok.pos()
field_typ := p.parse_type()
@ -739,6 +747,7 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
comments: comments
is_pub: true
has_prev_newline: has_prev_newline
has_break_line: has_break_line
}
info.fields << ast.StructField{
name: field_name
@ -746,6 +755,7 @@ fn (mut p Parser) interface_decl() ast.InterfaceDecl {
is_pub: true
is_mut: is_mut
has_prev_newline: has_prev_newline
has_break_line: has_break_line
}
}
}

View file

@ -265,7 +265,7 @@ fn vweb_tmpl_${fn_name}() string {
pos: start_of_line_pos + position
last_line: lines.len
}
reporter: .parser
reporter: .parser
})
continue
}
@ -280,7 +280,7 @@ fn vweb_tmpl_${fn_name}() string {
pos: start_of_line_pos + position
last_line: lines.len
}
reporter: .parser
reporter: .parser
})
continue
}
@ -298,7 +298,7 @@ fn vweb_tmpl_${fn_name}() string {
col: err.col()
last_line: lines.len
}
reporter: .parser
reporter: .parser
})
[]string{}
} else {
@ -311,7 +311,7 @@ fn vweb_tmpl_${fn_name}() string {
pos: start_of_line_pos
last_line: lines.len
}
reporter: .parser
reporter: .parser
})
[]string{}
}

View file

@ -16,8 +16,8 @@ fn test_array_filter_using_direct_closure() {
filenames := ['one', 'two', 'three']
files := filenames.map(fn (f string) File {
return File{
name: f
typ: if f == 'one' {
name: f
typ: if f == 'one' {
'file'
} else {
'dir'

View file

@ -32,7 +32,7 @@ fn test_main() {
association: &Association{
price: APrice{}
}
price: APrice{}
price: APrice{}
}
assert get_value_from_ref(&Association{

View file

@ -288,7 +288,7 @@ pub mut:
fn test_nested_pointer_smartcast() {
mut s := All_in_one{
ptr: &Sum1(Foo1{
ptr: &Sum1(Foo1{
a: 1
})
ptrs: [&SumAll(Sum2(Bar1{

View file

@ -11,7 +11,7 @@ pub fn PartialEmoji.parse(j json2.Any) !PartialEmoji {
match j {
map[string]json2.Any {
return PartialEmoji{
id: if s := j['id'] {
id: if s := j['id'] {
if s !is json2.Null {
?int(s.int())
} else {
@ -56,13 +56,13 @@ pub fn Button.parse(j json2.Any) !Button {
match j {
map[string]json2.Any {
return Button{
style: unsafe { ButtonStyle(j['style']!.int()) }
label: if s := j['label'] {
style: unsafe { ButtonStyle(j['style']!.int()) }
label: if s := j['label'] {
?string(s as string)
} else {
none
}
emoji: if o := j['emoji'] {
emoji: if o := j['emoji'] {
dump(PartialEmoji.parse(o)!)
?PartialEmoji(PartialEmoji.parse(o)!)
} else {
@ -73,12 +73,12 @@ pub fn Button.parse(j json2.Any) !Button {
} else {
none
}
url: if s := j['url'] {
url: if s := j['url'] {
?string(s as string)
} else {
none
}
disabled: if b := j['disabled'] {
disabled: if b := j['disabled'] {
?bool(b as bool)
} else {
none

View file

@ -76,12 +76,12 @@ pub enum Kind {
lsbr // [
nilsbr // #[
rsbr // ]
eq // ==
ne // !=
gt // >
lt // <
ge // >=
le // <=
eq // ==
ne // !=
gt // >
lt // <
ge // >=
le // <=
comment
nl
dot // .

View file

@ -1145,7 +1145,7 @@ pub fn (mut t Transformer) fn_decl_trace_calls(mut node ast.FnDecl) {
expr: ast.StringLiteral{
val: fname
}
typ: ast.string_type_idx
typ: ast.string_type_idx
},
]
}

View file

@ -54,7 +54,7 @@ pub fn (or_expr &OrExpr) desugar() Expr {
// args: [or_expr.expr.lhs, or_expr.expr.expr]
// }
// array.len
cond: InfixExpr{
cond: InfixExpr{
lhs: SelectorExpr{
lhs: or_expr.expr.lhs
rhs: Ident{
@ -64,7 +64,7 @@ pub fn (or_expr &OrExpr) desugar() Expr {
op: .gt
rhs: or_expr.expr.expr
}
stmts: [ExprStmt{
stmts: [ExprStmt{
expr: or_expr.expr
}]
else_expr: IfExpr{
@ -73,7 +73,7 @@ pub fn (or_expr &OrExpr) desugar() Expr {
}
} else {
return IfExpr{
cond: InfixExpr{
cond: InfixExpr{
lhs: or_expr.expr
op: .eq
rhs: BasicLiteral{

View file

@ -49,7 +49,7 @@ fn test_protect() {
form: {
csrf_config.token_name: token
}
req: http.Request{
req: http.Request{
method: .post
}
}
@ -82,7 +82,7 @@ fn test_timeout() {
form: {
short_time_config.token_name: token
}
req: http.Request{
req: http.Request{
method: .post
}
}
@ -107,7 +107,7 @@ fn test_valid_origin() {
form: {
csrf_config.token_name: token
}
req: req
req: req
}
mut valid := csrf.protect(mut ctx, csrf_config_origin)
@ -127,7 +127,7 @@ fn test_invalid_origin() {
form: {
csrf_config.token_name: token
}
req: req
req: req
}
mut valid := csrf.protect(mut ctx, csrf_config_origin)
@ -142,7 +142,7 @@ fn test_invalid_origin() {
form: {
csrf_config.token_name: token
}
req: req
req: req
}
valid = csrf.protect(mut ctx, csrf_config_origin)
@ -156,7 +156,7 @@ fn test_invalid_origin() {
form: {
csrf_config.token_name: token
}
req: req
req: req
}
valid = csrf.protect(mut ctx, csrf_config_origin)

View file

@ -90,7 +90,7 @@ fn test_bigger_content_length() {
header: http.new_header_from_map({
.content_length: '10'
})
data: data
data: data
})!
// Content-length is larger than the data sent, so the request should timeout
@ -105,7 +105,7 @@ fn test_smaller_content_length() {
header: http.new_header_from_map({
.content_length: '5'
})
data: data
data: data
})!
assert x.status() == .bad_request

View file

@ -108,7 +108,7 @@ fn test_valid_origin() {
form: {
csrf_config.token_name: token
}
req: req
req: req
}
mut valid := csrf.protect(mut ctx, csrf_config_origin)
@ -127,7 +127,7 @@ fn test_invalid_origin() {
form: {
csrf_config.token_name: token
}
req: req
req: req
}
mut valid := csrf.protect(mut ctx, csrf_config_origin)
@ -142,7 +142,7 @@ fn test_invalid_origin() {
form: {
csrf_config.token_name: token
}
req: req
req: req
}
valid = csrf.protect(mut ctx, csrf_config_origin)
@ -156,7 +156,7 @@ fn test_invalid_origin() {
form: {
csrf_config.token_name: token
}
req: req
req: req
}
valid = csrf.protect(mut ctx, csrf_config_origin)
@ -233,7 +233,7 @@ fn exit_after_timeout[T](mut app T, timeout_in_ms int) {
fn test_run_app_in_background() {
mut app := &App{
csrf: csrf.CsrfApp{
csrf: csrf.CsrfApp{
secret: 'my-256bit-secret'
allowed_hosts: [allowed_origin]
session_cookie: session_id_cookie_name

View file

@ -112,7 +112,7 @@ fn skip_bom(file_content string) string {
fn new_parser(srce string, convert_type bool) Parser {
src := skip_bom(srce)
return Parser{
scanner: &Scanner{
scanner: &Scanner{
text: src.bytes()
}
convert_type: convert_type

View file

@ -277,7 +277,7 @@ fn test_encoding_struct_with_pointers() {
association: &Association{
price: APrice{}
}
price: APrice{}
price: APrice{}
}
// println(value)
assert json.encode(value) == '{"association":{"price":{}},"price":{}}'
@ -314,7 +314,7 @@ fn test_nested_type() {
cities: [City{'Donlon'}, City{'Termanches'}]
},
]
users: {
users: {
'Foo': User{
age: 10
nums: [1, 2, 3]
@ -332,7 +332,7 @@ fn test_nested_type() {
pets: 'little boo'
}
}
extra: {
extra: {
'2': {
'n1': 2
'n2': 4

View file

@ -94,7 +94,7 @@ fn testsuite_begin() {
cookie_options: sessions.CookieOptions{
cookie_name: cookie_name
}
max_age: max_age
max_age: max_age
}
}

View file

@ -90,7 +90,7 @@ fn test_bigger_content_length() {
header: http.new_header_from_map({
.content_length: '10'
})
data: data
data: data
})!
// Content-length is larger than the data sent, so the request should timeout
@ -105,7 +105,7 @@ fn test_smaller_content_length() {
header: http.new_header_from_map({
.content_length: '5'
})
data: data
data: data
})!
assert x.status() == .bad_request