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

add unit tests for runtime/core - helpers #78

Merged
merged 2 commits into from
Oct 8, 2018

Conversation

esell
Copy link
Contributor

@esell esell commented Oct 8, 2018

** NOTE ** there are currently a few tests that are not passing (commented in code). need to dig a bit deeper and see what is going on...

This PR adds unit tests for runtime/core per issue #34.

@esell
Copy link
Contributor Author

esell commented Oct 8, 2018

@ziflex, would be interested to get your opinion on the strategy used in these tests as well as your thoughts on why some are failing (returning nil).

@ziflex
Copy link
Member

ziflex commented Oct 8, 2018

@esell I guess those cases are not covered in the utility function.

@ziflex
Copy link
Member

ziflex commented Oct 8, 2018

@esell here is an updated version of helper:

func IsNil(input interface{}) bool {
	val := reflect.ValueOf(input)
	kind := val.Kind()

	switch kind {
	case reflect.Ptr,
		reflect.Array,
		reflect.Slice,
		reflect.Map,
		reflect.Func,
		reflect.Interface,
		reflect.Chan:
		return val.IsNil()
	case reflect.Struct,
		reflect.UnsafePointer:
		return false
	case reflect.Invalid:
		return true
	default:
		return false
	}
}

If I missed something else - just add.

@esell
Copy link
Contributor Author

esell commented Oct 8, 2018

I took a look at https://golang.org/pkg/reflect/#Value.IsNil and it appears you got everything so i've updated the PR with those changes.

Copy link
Member

@ziflex ziflex left a comment

Choose a reason for hiding this comment

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

Great! Thanks for your PR!

@ziflex ziflex merged commit 0004667 into MontFerret:master Oct 8, 2018
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