v test-fmt: fix some embedded comments in expressions

pull/6615/head
Delyan Angelov 2020-10-14 22:51:16 +03:00
parent c33a748344
commit 46c5a2c8fc
10 changed files with 35 additions and 59 deletions

View File

@ -38,39 +38,18 @@ const (
const ( const (
// Tetros' 4 possible states are encoded in binaries // Tetros' 4 possible states are encoded in binaries
// 0000 0 0000 0 0000 0 0000 0 0000 0 0000 0
// 0000 0 0000 0 0000 0 0000 0 0011 3 0011 3
// 0110 6 0010 2 0011 3 0110 6 0001 1 0010 2
// 0110 6 0111 7 0110 6 0011 3 0001 1 0010 2
// There is a special case 1111, since 15 can't be used.
b_tetros = [ b_tetros = [
// 0000 0
// 0000 0
// 0110 6
// 0110 6
[66, 66, 66, 66], [66, 66, 66, 66],
// 0000 0
// 0000 0
// 0010 2
// 0111 7
[27, 131, 72, 232], [27, 131, 72, 232],
// 0000 0
// 0000 0
// 0011 3
// 0110 6
[36, 231, 36, 231], [36, 231, 36, 231],
// 0000 0
// 0000 0
// 0110 6
// 0011 3
[63, 132, 63, 132], [63, 132, 63, 132],
// 0000 0
// 0011 3
// 0001 1
// 0001 1
[311, 17, 223, 74], [311, 17, 223, 74],
// 0000 0
// 0011 3
// 0010 2
// 0010 2
[322, 71, 113, 47], [322, 71, 113, 47],
// Special case since 15 can't be used
// 1111
[1111, 9, 1111, 9], [1111, 9, 1111, 9],
] ]
// Each tetro has its unique color // Each tetro has its unique color

View File

@ -808,7 +808,8 @@ fn test_double_quote_inter() {
fn test_string_map() { fn test_string_map() {
$if windows { $if windows {
return // TODO // TODO
return
} }
original := 'Hello' original := 'Hello'
println('original.len = $original.len') println('original.len = $original.len')

View File

@ -18,35 +18,26 @@ pub fn utf32_to_str_no_malloc(code u32, buf voidptr) string {
icode := int(code) // Prevents doing casts everywhere icode := int(code) // Prevents doing casts everywhere
unsafe { unsafe {
mut buffer := byteptr(buf) mut buffer := byteptr(buf)
if icode <= 127/* 0x7F */ { if icode <= 127 { /* 0x7F */
buffer[0] = byte(icode) buffer[0] = byte(icode)
return tos(buffer, 1) return tos(buffer, 1)
} }
if icode <= 2047/* 0x7FF */ { if icode <= 2047 { /* 0x7FF */
buffer[0] = 192/*0xC0*/ | byte(icode>>6)/* 110xxxxx */ buffer[0] = 192 | byte(icode>>6) /* 0xC0 - 110xxxxx */
buffer[1] = 128 | byte(icode & 63) /* 0x80 - 0x3F - 10xxxxxx */
buffer[1] = 128/*0x80*/ | byte(icode & 63/*0x3F*/)/* 10xxxxxx */
return tos(buffer, 2) return tos(buffer, 2)
} }
if icode <= 65535/* 0xFFFF */ { if icode <= 65535 { /* 0xFFFF */
buffer[0] = 224/*0xE0*/ | byte(icode>>12)/* 1110xxxx */ buffer[0] = 224 | byte(icode>>12)/* 0xE0 - 1110xxxx */
buffer[1] = 128 | (byte(icode>>6) & 63) /* 0x80 - 0x3F - 10xxxxxx */
buffer[1] = 128/*0x80*/ | (byte(icode>>6) & 63/*0x3F*/)/* 10xxxxxx */ buffer[2] = 128 | byte(icode & 63) /* 0x80 - 0x3F - 10xxxxxx */
buffer[2] = 128/*0x80*/ | byte(icode & 63/*0x3F*/)/* 10xxxxxx */
return tos(buffer, 3) return tos(buffer, 3)
} }
if icode <= 1114111/* 0x10FFFF */ { if icode <= 1114111/* 0x10FFFF */ {
buffer[0] = 240/*0xF0*/ | byte(icode>>18)/* 11110xxx */ buffer[0] = 240 | byte(icode>>18) /* 0xF0 - 11110xxx */
buffer[1] = 128 | (byte(icode>>12) & 63) /* 0x80 - 0x3F - 10xxxxxx */
buffer[1] = 128/*0x80*/ | (byte(icode>>12) & 63/*0x3F*/)/* 10xxxxxx */ buffer[2] = 128 | (byte(icode>>6) & 63) /* 0x80 - 0x3F - 10xxxxxx */
buffer[3] = 128 | byte(icode & 63) /* 0x80 - 0x3F - 10xxxxxx */
buffer[2] = 128/*0x80*/ | (byte(icode>>6) & 63/*0x3F*/)/* 10xxxxxx */
buffer[3] = 128/*0x80*/ | byte(icode & 63/*0x3F*/)/* 10xxxxxx */
return tos(buffer, 4) return tos(buffer, 4)
} }
} }
@ -186,10 +177,14 @@ fn utf8_str_visible_length(s string) int {
} }
} else if c == 0xe1 || c == 0xe2 || c == 0xef { } else if c == 0xe1 || c == 0xe2 || c == 0xef {
r := (u32(c) << 16) | unsafe {(u32(s.str[i+1]) << 8) | s.str[i+2]} r := (u32(c) << 16) | unsafe {(u32(s.str[i+1]) << 8) | s.str[i+2]}
if (r >= 0xe1aab0 && r < 0xe1ac80) // diacritical marks extended // diacritical marks extended 0xe1aab0 - 0xe1ac80
|| (r >= 0xe1b780 && r < 0xe1b880) // diacritical marks supplement // diacritical marks supplement 0xe1b780 - 0xe1b880
|| (r >= 0xe28390 && r < 0xe28480) // diacritical marks for symbols // diacritical marks for symbols 0xe28390 - 0xe28480
|| (r >= 0xefb8a0 && r < 0xefb8b0) { // half marks // half marks 0xefb8a0 - 0xefb8b0
if (r >= 0xe1aab0 && r < 0xe1ac80)
|| (r >= 0xe1b780 && r < 0xe1b880)
|| (r >= 0xe28390 && r < 0xe28480)
|| (r >= 0xefb8a0 && r < 0xefb8b0) {
l-- l--
} }
} }

View File

@ -260,7 +260,8 @@ fn (mut cb Clipboard) start_listener(){
match event.@type { match event.@type {
C.DestroyNotify { C.DestroyNotify {
if event.xdestroywindow.window == cb.window { if event.xdestroywindow.window == cb.window {
return // we are done // we are done
return
} }
} }
C.SelectionClear { C.SelectionClear {

View File

@ -14,8 +14,8 @@ fn run_test(is_primary bool){
fn test_primary(){ fn test_primary(){
$if linux { $if linux {
return
//run_test(true) //run_test(true)
return
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved. // Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license // Use of this source code is governed by an MIT license
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
module hash module hash
interface Hasher { interface Hasher {

View File

@ -28,7 +28,8 @@ fn C.sg_apply_viewport(x int, y int, width int, height int, origin_top_left bool
fn C.sg_apply_scissor_rect(x int, y int, width int, height int, origin_top_left bool) fn C.sg_apply_scissor_rect(x int, y int, width int, height int, origin_top_left bool)
fn C.sg_apply_pipeline(pip C.sg_pipeline) fn C.sg_apply_pipeline(pip C.sg_pipeline)
fn C.sg_apply_bindings(bindings &C.sg_bindings) fn C.sg_apply_bindings(bindings &C.sg_bindings)
fn C.sg_apply_uniforms(stage int /*sg_shader_stage*/, ub_index int, data voidptr, num_bytes int) // stage == sg_shader_stage
fn C.sg_apply_uniforms(stage int, ub_index int, data voidptr, num_bytes int)
fn C.sg_draw(base_element int, num_elements int, num_instances int) fn C.sg_draw(base_element int, num_elements int, num_instances int)
fn C.sg_end_pass() fn C.sg_end_pass()
fn C.sg_commit() fn C.sg_commit()

View File

@ -56,8 +56,8 @@ fn test_select() {
} }
} }
// Use Gauß' formula for the first 2 contributions // Use Gauß' formula for the first 2 contributions
expected_sum := 2 * (300 * (300 - 1) / 2) +
// the 3rd contribution is `byte` and must be seen modulo 256 // the 3rd contribution is `byte` and must be seen modulo 256
expected_sum := 2 * (300 * (300 - 1) / 2) +
256 * (256 - 1) / 2 + 256 * (256 - 1) / 2 +
44 * (44 - 1) / 2 44 * (44 - 1) / 2
assert sum == expected_sum assert sum == expected_sum

View File

@ -76,8 +76,8 @@ fn test_select() {
} }
} }
// Use Gauß' formula for the first 2 contributions // Use Gauß' formula for the first 2 contributions
expected_sum := 2 * (300 * (300 - 1) / 2) +
// the 3rd contribution is `byte` and must be seen modulo 256 // the 3rd contribution is `byte` and must be seen modulo 256
expected_sum := 2 * (300 * (300 - 1) / 2) +
256 * (256 - 1) / 2 + 256 * (256 - 1) / 2 +
44 * (44 - 1) / 2 44 * (44 - 1) / 2
assert sum == expected_sum assert sum == expected_sum

View File

@ -85,8 +85,8 @@ fn test_select() {
} }
} }
// Use Gauß' formula for the first 2 contributions // Use Gauß' formula for the first 2 contributions
expected_sum := 2 * (300 * (300 - 1) / 2) +
// the 3rd contribution is `byte` and must be seen modulo 256 // the 3rd contribution is `byte` and must be seen modulo 256
expected_sum := 2 * (300 * (300 - 1) / 2) +
256 * (256 - 1) / 2 + 256 * (256 - 1) / 2 +
44 * (44 - 1) / 2 44 * (44 - 1) / 2
assert sum == expected_sum assert sum == expected_sum