This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(( [a, b] [c, d] )) evaulates to [a, b, c, d]
- Loading branch information
Alex Suraci and Dmitriy Kalinin
committed
Nov 1, 2013
1 parent
66aa9f4
commit b6cb3f4
Showing
3 changed files
with
49 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,58 @@ | ||
package dynaml | ||
|
||
import ( | ||
"github.com/vito/spiff/yaml" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("concatenation", func() { | ||
It("concatenates two strings", func() { | ||
expr := ConcatenationExpr{ | ||
StringExpr{"one"}, | ||
StringExpr{"two"}, | ||
} | ||
Context("when the left-hand side is a string", func() { | ||
Context("and the right-hand side is a string", func() { | ||
It("concatenates both strings", func() { | ||
expr := ConcatenationExpr{ | ||
StringExpr{"one"}, | ||
StringExpr{"two"}, | ||
} | ||
|
||
Expect(expr).To(EvaluateAs("onetwo", FakeBinding{})) | ||
}) | ||
Expect(expr).To(EvaluateAs("onetwo", FakeBinding{})) | ||
}) | ||
}) | ||
|
||
Context("when the left-hand side is not a string", func() { | ||
It("fails", func() { | ||
expr := ConcatenationExpr{ | ||
StringExpr{"one"}, | ||
IntegerExpr{42}, | ||
} | ||
Context("and the right-hand side is NOT a string", func() { | ||
It("fails", func() { | ||
expr := ConcatenationExpr{ | ||
StringExpr{"two"}, | ||
IntegerExpr{42}, | ||
} | ||
|
||
Expect(expr).To(FailToEvaluate(FakeBinding{})) | ||
Expect(expr).To(FailToEvaluate(FakeBinding{})) | ||
}) | ||
}) | ||
}) | ||
|
||
Context("when the right-hand side is not a string", func() { | ||
It("fails", func() { | ||
expr := ConcatenationExpr{ | ||
IntegerExpr{42}, | ||
StringExpr{"two"}, | ||
} | ||
Context("when the left-hand side is a list", func() { | ||
Context("and the right-hand side is a list", func() { | ||
It("concatenates both lists", func() { | ||
expr := ConcatenationExpr{ | ||
ListExpr{[]Expression{StringExpr{"one"}}}, | ||
ListExpr{[]Expression{StringExpr{"two"}}}, | ||
} | ||
|
||
Expect(expr).To(EvaluateAs([]yaml.Node{"one", "two"}, FakeBinding{})) | ||
}) | ||
}) | ||
|
||
Context("and the right-hand side is NOT a list", func() { | ||
It("fails", func() { | ||
expr := ConcatenationExpr{ | ||
IntegerExpr{42}, | ||
ListExpr{[]Expression{StringExpr{"two"}}}, | ||
} | ||
|
||
Expect(expr).To(FailToEvaluate(FakeBinding{})) | ||
Expect(expr).To(FailToEvaluate(FakeBinding{})) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters