Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Oct 22, 2024

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
Copy link
Member

@spytheman spytheman left a comment

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
71 of 78 checks passed
@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