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

Feat: Add testing for utils & delete extraneous code; #145

Open
wants to merge 22 commits into
base: dev
Choose a base branch
from
Open

Conversation

5-pebbles
Copy link
Collaborator

@5-pebbles 5-pebbles commented Jun 12, 2024

I deleted a substantial portion of utils: rgb_to_hsv, hsv_to_rbg, darken, and lighten.

And the utils that did survive now have some tests.

@5-pebbles 5-pebbles self-assigned this Jun 12, 2024
@5-pebbles
Copy link
Collaborator Author

I am going to make tests echo the output. I don't think it will break anything, and I want to see my new error messages...

@5-pebbles 5-pebbles force-pushed the tests branch 2 times, most recently from 2b36c3f to 81051d9 Compare June 12, 2024 18:39
@5-pebbles 5-pebbles changed the title Feat: Add state and utils testing modules; Feat: Add utils testing modules; Jun 15, 2024
lua/nordic/utils.lua Outdated Show resolved Hide resolved
lua/nordic/utils.lua Show resolved Hide resolved
lua/nordic/utils.lua Outdated Show resolved Hide resolved
@5-pebbles
Copy link
Collaborator Author

Alright, that's all of the utils tested or deleted.

@5-pebbles 5-pebbles marked this pull request as ready for review June 15, 2024 19:09
@5-pebbles 5-pebbles requested a review from AlexvZyl June 15, 2024 19:09
@5-pebbles 5-pebbles changed the title Feat: Add utils testing modules; Feat: Add testing for utils & delete extraneous code; Jun 15, 2024
@5-pebbles 5-pebbles linked an issue Jun 15, 2024 that may be closed by this pull request

local M = {}

function M.get_groups()
local native = require('nordic.groups.native').get_groups()
local integrations = require('nordic.groups.integrations').get_groups()
local groups = merge(native, integrations)
local groups = merge_inplace(native, integrations)
Copy link
Owner

Choose a reason for hiding this comment

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

Pretty sure this should not be a merge inplace? We do not want to modify native here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It works because get_groups creates a new table each time; however, I agree it's not very clear. merge and merge_inplace do almost the same thing, so it feels weird to have both.

I could revert that commit or I could make it more clear with something like this:

local native = require('nordic.groups.native').get_groups()
local integrations = require('nordic.groups.integrations').get_groups()

local groups = {}
merge_inplace(groups, integrations)
merge_inplace(groups, integrations)

Which ever you think is better.

Copy link
Owner

@AlexvZyl AlexvZyl Jun 16, 2024

Choose a reason for hiding this comment

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

Merge and merge inplace are different enough that we would want both, it is very common to have both.

So I think we should:

  • Keep both.
  • If you want to keep using merge_inplace in this scenario, please change it the way you suggested. Just a bit more clear what is going on.

Copy link
Collaborator Author

@5-pebbles 5-pebbles Jun 16, 2024

Choose a reason for hiding this comment

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

done in: 8c8fff4

lua/nordic/tests/init.lua Show resolved Hide resolved
end
end

function M.assert_eq(left, right, message)
Copy link
Owner

Choose a reason for hiding this comment

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

Did you get this function from some other module?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's inspired by Rust's assert_eq macro, but all the code is new.

Copy link
Owner

Choose a reason for hiding this comment

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

Sweet. Maybe we should rewrite the theme in Rust?...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have been tempted at times: https://github.com/KillTheMule/nvim-rs ;)

@AlexvZyl
Copy link
Owner

Nice work on this PR, you really went all out :)

@AlexvZyl
Copy link
Owner

Closes #140.

@5-pebbles
Copy link
Collaborator Author

I think it's good to go!

@5-pebbles
Copy link
Collaborator Author

5-pebbles commented Jun 16, 2024

The one issue I still have with merge is that it does return a reference if one of the tables is empty... I have a few miscellaneous code changes like that, but I will make an issue and then a PR for those at a later date.

It's no longer being used anywhere, so it won't break anything in the meantime.

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.

CI: Add tests for utils
2 participants