Skip to content

builtin: improve fixed_array_any_all_test.v (related #22609) - #22621

Merged
spytheman merged 1 commit into
vlang:masterfrom
yuyi98:test_add_lambda_expr
Oct 22, 2024
Merged

spytheman merged 1 commit into
vlang:masterfrom
yuyi98:test_add_lambda_expr

Conversation

@yuyi98

@yuyi98 yuyi98 commented Oct 22, 2024 •

Copy link
Copy Markdown
Member

This PR improve fixed_array_any_all_test.v (related #22609).

  • Add lambda expr tests.
fn test_any_all_of_ints() {
	ia := [1, 2, 3]!

	assert ia.any(it > 2)
	assert ia.any(|x| x > 2)

	assert !ia.all(it > 1)
	assert !ia.all(|x| x > 1)

	assert ia.any(it == 2)
	assert ia.any(|x| x == 2)

	assert !ia.all(it == 3)
	assert !ia.all(|x| x == 3)
}

fn test_any_all_of_strings() {
	sa := ['a', 'b', 'c']!

	assert sa.any(it == 'b')
	assert sa.any(|x| x == 'b')

	assert !sa.all(it == 'c')
	assert !sa.all(|x| x == 'c')
}

fn test_any_all_of_voidptrs() {
	pa := [voidptr(123), voidptr(45), voidptr(99)]!

	assert pa.any(it == voidptr(45))
	assert pa.any(|x| x == voidptr(45))

	assert !pa.all(it == voidptr(123))
	assert !pa.all(|x| x == voidptr(123))
}

fn a() {}

fn b() {}

fn c() {}

fn v() {}

fn test_any_all_of_fns() {
	fa := [a, b, c]!

	assert fa.any(it == b)
	assert fa.any(|x| x == b)

	assert !fa.all(it == v)
	assert !fa.all(|x| x == v)
}

Huly®: V_0.6-21070

@spytheman spytheman changed the title test: improve fixed_array_any_all_test.v (related #22609) builtin: improve fixed_array_any_all_test.v (related #22609) Oct 22, 2024
@spytheman spytheman changed the title builtin: improve fixed_array_any_all_test.v (related #22609) builtin: improve fixed_array_any_all_test.v (related #22609) Oct 22, 2024

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work.

@spytheman
spytheman merged commit ea8ae7b into vlang:master Oct 22, 2024
@yuyi98
yuyi98 deleted the test_add_lambda_expr branch October 23, 2024 03:38
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