Skip to content

test: supplement test cases in fixed_array_const_size_test.v (related #19269) - #19303

Merged
spytheman merged 1 commit into
vlang:masterfrom
yuyi98:supplement_test_cases
Sep 8, 2023
Merged

spytheman merged 1 commit into
vlang:masterfrom
yuyi98:supplement_test_cases

Conversation

@yuyi98

@yuyi98 yuyi98 commented Sep 7, 2023

Copy link
Copy Markdown
Member

This PR supplement test cases in fixed_array_const_size_test.v (related #19269).

const (
	rows = 2
	cols = 3
)

struct Matrix1 {
	data [rows * cols]int
}

struct Matrix2 {
	data [rows * cols + 4]int
}

struct Matrix3 {
	data [rows * 4 - 2 * cols]int
}

struct Matrix4 {
	data [5 * rows - cols * 2]int
}

struct Matrix5 {
	data [5 * rows / 2]int
}

struct Matrix6 {
	data [5 * rows / 2 + 1]int
}

fn main() {
	mat1 := Matrix1{}
	println(mat1)
	assert mat1.data.len == 6

	mat2 := Matrix2{}
	println(mat2)
	assert mat2.data.len == 10

	mat3 := Matrix3{}
	println(mat3)
	assert mat3.data.len == 2

	mat4 := Matrix4{}
	println(mat4)
	assert mat4.data.len == 4

	mat5 := Matrix5{}
	println(mat5)
	assert mat5.data.len == 5

	mat6 := Matrix6{}
	println(mat6)
	assert mat6.data.len == 6
}

PS D:\Test\v\tt1> v run .
Matrix1{
    data: [0, 0, 0, 0, 0, 0]
}
Matrix2{
    data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
}
Matrix3{
    data: [0, 0]
}
Matrix4{
    data: [0, 0, 0, 0]
}
Matrix5{
    data: [0, 0, 0, 0, 0]
}
Matrix6{
    data: [0, 0, 0, 0, 0, 0]
}

@spytheman
spytheman merged commit 66c62b9 into vlang:master Sep 8, 2023
@yuyi98
yuyi98 deleted the supplement_test_cases branch September 8, 2023 05:42
spytheman added a commit to Spydr06/v that referenced this pull request Sep 8, 2023
* master: (128 commits)
  ci: update containers_ci.yml to not try to install libexecinfo-static, which is not present on the latest Alpine image
  checker: disallow module name duplicates in local names (vlang#18118)
  cgen: cleanup go_before_stmt(0) (vlang#19308)
  parser: disallow using `sql` as name (vlang#19298)
  fmt: cleanup fmt comments (vlang#19306)
  tests: supplement test cases in fixed_array_const_size_test.v (vlang#19303)
  vdoc: prevent main-content outline with certain devices / browsers (vlang#19304)
  cgen: fix printing struct with thread field (vlang#19302)
  vlib: replace macros that resolve to __builtin_bswapnn calls for tcc (vlang#19305)
  time: add `MMM` in the doc comment for parse_format() (vlang#19299)
  os: include sys/sysctl.h on FreeBSD to avoid implicit definition of sysctl function (vlang#19293)
  parser, transformer: fix transformer.infix_expr() and cleanup parse_types.v (related vlang#19269) (vlang#19276)
  fmt: simplify the processing logic for removing inline comments (vlang#19297)
  db.pg: allow postgres connection using service definitions (vlang#19288)
  builtin: use `libgc-threaded` on FreeBSD, to get the threaded version of libgc (vlang#19294)
  ci: test the pure V math versions without .c.v overrides on the CI too (vlang#19292)
  all: support `./v -exclude @vlib/math/*.c.v vlib/math/math_test.v`, for using the pure V math module implementation, without the .c.v overrides there. (vlang#19290)
  .cirrus.yml: change test_zip_modules -> test_zip_modules_script, so that the CI can recognise the new task name and execute it
  thirdparty/zip: properly include utime.h and set defines for FreeBSD (vlang#19285)
  math: fix pure v math.pow (vlang#19287)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants