Skip to content

Commit

Permalink
#234 Updated code as code review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzhang6222 committed May 25, 2020
1 parent a5d4bd4 commit 5f912d0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/std-seq.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Usage:
| example | equals |
|:-|:-|
| `//seq.has_prefix("I'm", "I'm running out of stuff to write")` | `true` |
| `//seq.has_prefix("to write", "I'm running out of stuff to write")` | `{}` which is equal to `false` |
| `//seq.has_prefix("to write", "I'm running out of stuff to write")` | `false` |
| `//seq.has_prefix(['A'],['A','B','C'])` | `true` |
| `//seq.has_prefix([1, 2],[1, 2, 3])` | `true` |
| `//seq.has_prefix([[1, 2]],[[1, 2], [3]])` | `true` |
Expand Down
8 changes: 4 additions & 4 deletions syntax/std_seq.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func stdSeq() rel.Attr {
return rel.NewTupleAttr("seq",
rel.NewNativeFunctionAttr("concat", stdSeqConcat),
rel.NewNativeFunctionAttr("repeat", stdSeqRepeat),
createNestedFuncAttr("contains", 2, func(args ...rel.Value) rel.Value {
createNestedFuncAttr("contains", 2, func(args ...rel.Value) rel.Value { //nolint:dupl
return includingProcess(func(args ...rel.Value) rel.Value {
sub, subject := args[0], args[1]
return rel.NewBool(strings.Contains(mustAsString(subject), mustAsString(sub)))
Expand All @@ -79,7 +79,7 @@ func stdSeq() rel.Attr {
},
args...)
}),
createNestedFuncAttr("has_prefix", 2, func(args ...rel.Value) rel.Value {
createNestedFuncAttr("has_prefix", 2, func(args ...rel.Value) rel.Value { //nolint:dupl
return includingProcess(func(args ...rel.Value) rel.Value {
sub, subject := args[0], args[1]
return rel.NewBool(strings.HasPrefix(mustAsString(subject), mustAsString(sub)))
Expand All @@ -94,7 +94,7 @@ func stdSeq() rel.Attr {
},
args...)
}),
createNestedFuncAttr("has_suffix", 2, func(args ...rel.Value) rel.Value {
createNestedFuncAttr("has_suffix", 2, func(args ...rel.Value) rel.Value { //nolint:dupl
return includingProcess(func(args ...rel.Value) rel.Value {
suffix, subject := args[0], args[1]
return rel.NewBool(strings.HasSuffix(mustAsString(subject), mustAsString(suffix)))
Expand Down Expand Up @@ -226,7 +226,7 @@ func includingProcess(
case rel.Bytes:
return bytesHandler(args...)
case rel.GenericSet:
if _, isSet := sub.(rel.GenericSet); isSet {
if emptySet, isSet := sub.(rel.GenericSet); isSet && !emptySet.IsTrue() {
return rel.NewBool(true)
}
}
Expand Down
2 changes: 1 addition & 1 deletion syntax/std_seq_contains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestStrContains(t *testing.T) {
assertExprPanics(t, `//seq.contains(1, "ABC")`)
}

func TestArrayContains(t *testing.T) {
func TestArrayContains(t *testing.T) { //nolint:dupl
t.Parallel()
AssertCodesEvalToSameValue(t, `true`, `//seq.contains(['A'],['A', 'D','E'])`)
AssertCodesEvalToSameValue(t, `true`, `//seq.contains(['E'],['A','C','E'])`)
Expand Down
2 changes: 1 addition & 1 deletion syntax/std_seq_split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestStrSplit(t *testing.T) {
assertExprPanics(t, `//seq.split(1,"ABC")`)
}

func TestArraySplit(t *testing.T) {
func TestArraySplit(t *testing.T) { //nolint:dupl
t.Parallel()
AssertCodesEvalToSameValue(t, `[['A'], ['B']]`,
`//seq.split([],['A', 'B'])`)
Expand Down

0 comments on commit 5f912d0

Please sign in to comment.