-
Notifications
You must be signed in to change notification settings - Fork 1
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 shift and unshift method #16
Conversation
tlayh
commented
Nov 5, 2019
- adding a shift and unshift function to pugtemplate
- added additional tests to existing functions
@bastianccm The tests are only comparing the items parts of the array. Currently, the methods, also for pop and push, are not manipulating the interface part of the array. Is this fine like it is? |
Hi @tlayh what do you mean by "Currently, the methods, also for pop and push, are not manipulating the interface part of the array. Is this fine like it is?"? Can you give an example? |
Taking the unit test for unshift as an example, if I compare the the array instead of comparing the items of the array, the unit test fails with the following: expected: &pugjs.Array{items:[]pugjs.Object{"first", "something", "test"}, o:[]string{"first", "something", "test"}} The item part is correct, the o: part fails. Does this help as an example |
That is fine. Can you resolve the conflicts? Then we can merge it. |
Resolved. |
pugjs/types.go
Outdated
func (a *Array) Shift() Object { | ||
if len(a.items) > 0 { | ||
first := a.items[0] | ||
a.items = a.items[1:len(a.items)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could even be shorter, couldn't it:
a.items = a.items[1:len(a.items)] | |
a.items = a.items[1:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it. Unit tests are telling me that it is still working