From b503c071dae51dd1fed738abd0735c2d811a2f67 Mon Sep 17 00:00:00 2001 From: Zhang Eric Date: Thu, 21 May 2020 16:44:24 +0800 Subject: [PATCH] #234 Removed unnecessary code as review comment. --- syntax/std_seq_array_helper.go | 7 ------- syntax/std_seq_join_test.go | 3 +++ syntax/std_seq_sub_test.go | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/syntax/std_seq_array_helper.go b/syntax/std_seq_array_helper.go index 98d153da..715908d1 100644 --- a/syntax/std_seq_array_helper.go +++ b/syntax/std_seq_array_helper.go @@ -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() { @@ -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() { diff --git a/syntax/std_seq_join_test.go b/syntax/std_seq_join_test.go index 4bf66ea3..7abb4e30 100644 --- a/syntax/std_seq_join_test.go +++ b/syntax/std_seq_join_test.go @@ -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])`) } diff --git a/syntax/std_seq_sub_test.go b/syntax/std_seq_sub_test.go index 45d2b327..53df3344 100644 --- a/syntax/std_seq_sub_test.go +++ b/syntax/std_seq_sub_test.go @@ -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]])`)