Skip to content

Commit

Permalink
#234 Removed unnecessary code as review comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzhang6222 committed May 21, 2020
1 parent 520d461 commit b503c07
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
7 changes: 0 additions & 7 deletions syntax/std_seq_array_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ func arraySub(old, new rel.Value, subject rel.Array) rel.Value {
oldArray := convert2Array(old)
newArray := convert2Array(new)

if !oldArray.IsTrue() && !new.IsTrue() {
return subject
}

result := make([]rel.Value, 0, subject.Count())
if !old.IsTrue() {
for _, e := range subject.Values() {
Expand Down Expand Up @@ -70,9 +66,6 @@ func arraySplit(delimiter rel.Value, subject rel.Array) rel.Value {
// Joins array joiner to subject.
func arrayJoin(joiner rel.Value, subject rel.Array) rel.Value {
joinerArray := convert2Array(joiner)
if !joinerArray.IsTrue() || !subject.IsTrue() {
return subject
}

result := make([]rel.Value, 0, subject.Count())
for i, value := range subject.Values() {
Expand Down
3 changes: 3 additions & 0 deletions syntax/std_seq_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ func TestArrayJoin(t *testing.T) {
AssertCodesEvalToSameValue(t, `[]`, `//seq.join([],[])`)
AssertCodesEvalToSameValue(t, `[]`, `//seq.join([1],[])`)

AssertCodesEvalToSameValue(t, `[1, 2, 3, 4]`, `//seq.join([], [[1, 2], [3, 4]])`)
AssertCodesEvalToSameValue(t, `[[1, 2], 3, 4]`, `//seq.join([], [[[1, 2]], [3, 4]])`)

assertExprPanics(t, `//seq.join(1, [1,2,3,4,5])`)
assertExprPanics(t, `//seq.join('A', [1,2])`)
}
Expand Down
1 change: 1 addition & 0 deletions syntax/std_seq_sub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestArraySubEdgeCases(t *testing.T) {
AssertCodesEvalToSameValue(t, `[[1,2]]`, `//seq.sub( [],[[1,2]], [])`)
AssertCodesEvalToSameValue(t, `[]`, `//seq.sub( [1],[], [])`)
AssertCodesEvalToSameValue(t, `[1,2,3]`, `//seq.sub( [],[], [1,2,3])`)
AssertCodesEvalToSameValue(t, `[[1,2],3]`, `//seq.sub( [],[], [[1,2],3])`)
AssertCodesEvalToSameValue(t, `[4,1,4,2,4,3,4]`, `//seq.sub( [], [4],[1,2,3])`)
AssertCodesEvalToSameValue(t, `[4,[1,2],4,[3,4],4]`, `//seq.sub( [], [4],[[1,2],[3,4]])`)
AssertCodesEvalToSameValue(t, `[[4],[1,2],[4],[3,4],[4]]`, `//seq.sub( [], [[4]],[[1,2],[3,4]])`)
Expand Down

0 comments on commit b503c07

Please sign in to comment.