Repository: cayleygraph/cayley
Pull request #926 (2020-03-19 03:18:26)

LinkedQL: Better Steps Test
In steps_test, update all tests to use valid IRIs and fix all lint warnings

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/cayleygraph/cayley/926)
<!-- Reviewable:end -->



Patch:
diff --git a/query/linkedql/property_path.go b/query/linkedql/property_path.go
index d823757..d9f013e 100644
--- a/query/linkedql/property_path.go
+++ b/query/linkedql/property_path.go
@@ -18,6 +18,11 @@ type PropertyPath struct {
 	PropertyPathI
 }
 
+// NewPropertyPath creates a PropertyPath from a value that can be casted to PropertyPath
+func NewPropertyPath(p PropertyPathI) PropertyPath {
+	return PropertyPath{PropertyPathI: p}
+}
+
 // Description implements Step.
 func (*PropertyPath) Description() string {
 	return "PropertyPath is a string, multiple strins or path describing a set of properties"


Test patch:
diff --git a/query/linkedql/steps/steps_test.go b/query/linkedql/steps/steps_test.go
index 1ff7294..ef9dcb4 100644
--- a/query/linkedql/steps/steps_test.go
+++ b/query/linkedql/steps/steps_test.go
@@ -8,11 +8,29 @@ import (
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/quad"
 	"github.com/cayleygraph/quad/voc"
+	"github.com/cayleygraph/quad/voc/xsd"
 	"github.com/stretchr/testify/require"
 )
 
+var (
+	exNS      = "http://example.org/"
+	alice     = quad.IRI(exNS + "alice")
+	bob       = quad.IRI(exNS + "bob")
+	dan       = quad.IRI(exNS + "dan")
+	likes     = quad.IRI(exNS + "likes")
+	likesName = quad.IRI(exNS + "likesName")
+	name      = quad.IRI(exNS + "name")
+	person    = quad.IRI(exNS + "person")
+	liker     = quad.IRI(exNS + "liker")
+	liked     = quad.IRI(exNS + "liked")
+)
+
+func newQuad(subject quad.Value, predicate quad.Value, object quad.Value, label quad.Value) quad.Quad {
+	return quad.Quad{Subject: subject, Predicate: predicate, Object: object, Label: label}
+}
+
 var singleQuadData = []quad.Quad{
-	quad.MakeIRI("alice", "likes", "bob", ""),
+	newQuad(alice, likes, bob, nil),
 }
 
 var testCases = []struct {
@@ -24,9 +42,9 @@ var testCases = []struct {
 	{
 		name:  "All Entities",
 		data:  singleQuadData,
-		query: &Entities{Identifiers: []linkedql.EntityIdentifier{linkedql.EntityIdentifierString("alice")}},
+		query: &Entities{Identifiers: []linkedql.EntityIdentifier{linkedql.EntityIdentifierString(alice)}},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
+			map[string]string{"@id": string(alice)},
 		},
 	},
 	{
@@ -34,30 +52,26 @@ var testCases = []struct {
 		data:  singleQuadData,
 		query: &Vertex{Values: nil},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
-			map[string]string{"@id": "likes"},
-			map[string]string{"@id": "bob"},
+			map[string]string{"@id": string(alice)},
+			map[string]string{"@id": string(likes)},
+			map[string]string{"@id": string(bob)},
 		},
 	},
 	{
 		name: "Select",
 		data: singleQuadData,
 		query: &Select{
-			From: &As{
-				From: &Visit{
-					From: &As{
-						From: &Vertex{},
-						Name: "liker",
-					},
-					Properties: linkedql.PropertyPath{&Vertex{Values: []quad.Value{quad.IRI("likes")}}},
+			From: &Visit{
+				From: &As{
+					From: &Vertex{},
+					Name: string(liker),
 				},
-				Name: "liked",
+				Properties: linkedql.NewPropertyPath(linkedql.PropertyIRI(likes)),
 			},
 		},
 		results: []interface{}{
 			map[string]interface{}{
-				"liker": map[string]string{"@id": "alice"},
-				"liked": map[string]string{"@id": "bob"},
+				string(liker): map[string]string{"@id": string(alice)},
 			},
 		},
 	},
@@ -65,21 +79,21 @@ var testCases = []struct {
 		name: "Select with tags",
 		data: singleQuadData,
 		query: &Select{
-			Tags: []string{"liker"},
+			Tags: []string{string(liker)},
 			From: &As{
 				From: &Visit{
 					From: &As{
 						From: &Vertex{},
-						Name: "liker",
+						Name: string(liker),
 					},
-					Properties: linkedql.PropertyPath{&Vertex{Values: []quad.Value{quad.IRI("likes")}}},
+					Properties: linkedql.NewPropertyPath(linkedql.PropertyIRI(likes)),
 				},
 				Name: "liked",
 			},
 		},
 		results: []interface{}{
 			map[string]interface{}{
-				"liker": map[string]string{"@id": "alice"},
+				string(liker): map[string]string{"@id": string(alice)},
 			},
 		},
 	},
@@ -89,34 +103,34 @@ var testCases = []struct {
 		query: &Back{
 			From: &Visit{
 				From: &Vertex{
-					Values: []quad.Value{quad.IRI("alice")},
+					Values: []quad.Value{alice},
 				},
-				Properties: linkedql.PropertyPath{&Vertex{
+				Properties: linkedql.NewPropertyPath(&Vertex{
 					Values: []quad.Value{
-						quad.IRI("likes"),
+						likes,
 					},
-				}},
+				}),
 			},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
+			map[string]string{"@id": string(alice)},
 		},
 	},
 	{
 		name: "Both",
 		data: []quad.Quad{
-			quad.MakeIRI("alice", "likes", "bob", ""),
-			quad.MakeIRI("bob", "likes", "dan", ""),
+			newQuad(dan, likes, bob, nil),
+			newQuad(bob, likes, alice, nil),
 		},
 		query: &Both{
 			From: &Vertex{
-				Values: []quad.Value{quad.IRI("bob")},
+				Values: []quad.Value{bob},
 			},
-			Properties: linkedql.PropertyPath{&Vertex{Values: []quad.Value{quad.IRI("likes")}}},
+			Properties: linkedql.NewPropertyPath(linkedql.PropertyIRI(likes)),
 		},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
-			map[string]string{"@id": "dan"},
+			map[string]string{"@id": string(dan)},
+			map[string]string{"@id": string(alice)},
 		},
 	},
 	{
@@ -126,7 +140,7 @@ var testCases = []struct {
 			From: &Vertex{Values: []quad.Value{}},
 		},
 		results: []interface{}{
-			map[string]string{"@value": "4", "@type": "xsd:integer"},
+			map[string]string{"@value": "4", "@type": xsd.Integer},
 		},
 	},
 	{
@@ -134,27 +148,24 @@ var testCases = []struct {
 		data: singleQuadData,
 		query: &Difference{
 			From: &Vertex{
-				Values: []quad.Value{quad.IRI("alice"), quad.IRI("likes")},
+				Values: []quad.Value{alice, likes},
 			},
 			Steps: []linkedql.PathStep{
 				&Vertex{
-					Values: []quad.Value{quad.IRI("likes")},
+					Values: []quad.Value{likes},
 				},
 			},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
+			map[string]string{"@id": string(alice)},
 		},
 	},
 	{
 		name: "RegExp",
 		data: []quad.Quad{
-			{Subject: quad.IRI("alice"), Predicate: quad.IRI("name"), Object: quad.String("Alice"), Label: nil},
-		},
-		query: &RegExp{
-			From:    &Vertex{Values: []quad.Value{}},
-			Pattern: "A",
+			{Subject: alice, Predicate: name, Object: quad.String("Alice"), Label: nil},
 		},
+		query: &RegExp{Pattern: "A", From: &Vertex{Values: []quad.Value{}}},
 		results: []interface{}{
 			"Alice",
 		},
@@ -162,21 +173,18 @@ var testCases = []struct {
 	{
 		name: "Like",
 		data: []quad.Quad{
-			{Subject: quad.IRI("alice"), Predicate: quad.IRI("name"), Object: quad.String("Alice"), Label: nil},
-		},
-		query: &Like{
-			From:    &Vertex{Values: []quad.Value{}},
-			Pattern: "a%",
+			{Subject: alice, Predicate: name, Object: quad.String("Alice"), Label: nil},
 		},
+		query: &Like{Pattern: "%ali%", From: &Vertex{Values: []quad.Value{}}},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
+			map[string]string{"@id": string(alice)},
 		},
 	},
 	{
 		name: "Filter LessThan",
 		data: []quad.Quad{
-			{Subject: quad.IRI("alice"), Predicate: quad.IRI("name"), Object: quad.Int(0), Label: nil},
-			{Subject: quad.IRI("alice"), Predicate: quad.IRI("name"), Object: quad.Int(1), Label: nil},
+			{Subject: alice, Predicate: name, Object: quad.Int(0), Label: nil},
+			{Subject: alice, Predicate: name, Object: quad.Int(1), Label: nil},
 		},
 		query: &LessThan{
 			From:  &Vertex{Values: []quad.Value{}},
@@ -189,8 +197,8 @@ var testCases = []struct {
 	{
 		name: "Filter GreaterThan",
 		data: []quad.Quad{
-			{Subject: quad.IRI("alice"), Predicate: quad.IRI("name"), Object: quad.Int(0), Label: nil},
-			{Subject: quad.IRI("alice"), Predicate: quad.IRI("name"), Object: quad.Int(1), Label: nil},
+			{Subject: alice, Predicate: name, Object: quad.Int(0), Label: nil},
+			{Subject: alice, Predicate: name, Object: quad.Int(1), Label: nil},
 		},
 		query: &GreaterThan{
 			From:  &Vertex{Values: []quad.Value{}},
@@ -203,9 +211,9 @@ var testCases = []struct {
 	{
 		name: "Filter LessThanEquals",
 		data: []quad.Quad{
-			{Subject: quad.IRI("alice"), Predicate: quad.IRI("name"), Object: quad.Int(-1), Label: nil},
-			{Subject: quad.IRI("alice"), Predicate: quad.IRI("name"), Object: quad.Int(0), Label: nil},
-			{Subject: quad.IRI("alice"), Predicate: quad.IRI("name"), Object: quad.Int(1), Label: nil},
+			{Subject: alice, Predicate: name, Object: quad.Int(-1), Label: nil},
+			{Subject: alice, Predicate: name, Object: quad.Int(0), Label: nil},
+			{Subject: alice, Predicate: name, Object: quad.Int(1), Label: nil},
 		},
 		query: &LessThanEquals{
 			From:  &Vertex{Values: []quad.Value{}},
@@ -219,9 +227,9 @@ var testCases = []struct {
 	{
 		name: "Filter GreaterThanEquals",
 		data: []quad.Quad{
-			{Subject: quad.IRI("alice"), Predicate: quad.IRI("name"), Object: quad.Int(0), Label: nil},
-			{Subject: quad.IRI("alice"), Predicate: quad.IRI("name"), Object: quad.Int(1), Label: nil},
-			{Subject: quad.IRI("alice"), Predicate: quad.IRI("name"), Object: quad.Int(2), Label: nil},
+			{Subject: alice, Predicate: name, Object: quad.Int(0), Label: nil},
+			{Subject: alice, Predicate: name, Object: quad.Int(1), Label: nil},
+			{Subject: alice, Predicate: name, Object: quad.Int(2), Label: nil},
 		},
 		query: &GreaterThanEquals{
 			From:  &Vertex{Values: []quad.Value{}},
@@ -239,13 +247,13 @@ var testCases = []struct {
 			From: &Vertex{
 				Values: []quad.Value{},
 			},
-			Property: linkedql.PropertyPath{&Vertex{
-				Values: []quad.Value{quad.IRI("likes")},
-			}},
-			Values: []quad.Value{quad.IRI("bob")},
+			Property: linkedql.NewPropertyPath(&Vertex{
+				Values: []quad.Value{likes},
+			}),
+			Values: []quad.Value{bob},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
+			map[string]string{"@id": string(alice)},
 		},
 	},
 	{
@@ -255,13 +263,13 @@ var testCases = []struct {
 			From: &Vertex{
 				Values: []quad.Value{},
 			},
-			Property: linkedql.PropertyPath{&Vertex{
-				Values: []quad.Value{quad.IRI("likes")},
-			}},
-			Values: []quad.Value{quad.IRI("alice")},
+			Property: linkedql.NewPropertyPath(&Vertex{
+				Values: []quad.Value{likes},
+			}),
+			Values: []quad.Value{alice},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "bob"},
+			map[string]string{"@id": string(bob)},
 		},
 	},
 	{
@@ -269,10 +277,10 @@ var testCases = []struct {
 		data: singleQuadData,
 		query: &VisitReverse{
 			From:       &Vertex{Values: []quad.Value{}},
-			Properties: linkedql.PropertyPath{&Vertex{Values: []quad.Value{quad.IRI("likes")}}},
+			Properties: linkedql.NewPropertyPath(linkedql.PropertyIRI(likes)),
 		},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
+			map[string]string{"@id": string(alice)},
 		},
 	},
 	{
@@ -282,47 +290,47 @@ var testCases = []struct {
 			From: &Vertex{Values: []quad.Value{}},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "likes"},
+			map[string]string{"@id": string(likes)},
 		},
 	},
 	{
 		name: "Intersect",
 		data: []quad.Quad{
-			quad.MakeIRI("bob", "likes", "alice", ""),
-			quad.MakeIRI("dani", "likes", "alice", ""),
+			newQuad(bob, likes, alice, nil),
+			newQuad(dan, likes, alice, nil),
 		},
 		query: &Intersect{
 			From: &Visit{
-				From: &Vertex{Values: []quad.Value{quad.IRI("bob")}},
-				Properties: linkedql.PropertyPath{&Vertex{
-					Values: []quad.Value{quad.IRI("likes")},
-				}},
+				From: &Vertex{Values: []quad.Value{bob}},
+				Properties: linkedql.NewPropertyPath(&Vertex{
+					Values: []quad.Value{likes},
+				}),
 			},
 			Steps: []linkedql.PathStep{
 				&Visit{
-					From:       &Vertex{Values: []quad.Value{quad.IRI("bob")}},
-					Properties: linkedql.PropertyPath{&Vertex{Values: []quad.Value{quad.IRI("likes")}}},
+					From:       &Vertex{Values: []quad.Value{bob}},
+					Properties: linkedql.NewPropertyPath(linkedql.PropertyIRI(likes)),
 				},
 			},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
+			map[string]string{"@id": string(alice)},
 		},
 	},
 	{
 		name: "Is",
 		data: singleQuadData,
 		query: &Is{
-			Values: []quad.Value{quad.IRI("bob")},
+			Values: []quad.Value{bob},
 			From: &Visit{
-				From: &Vertex{Values: []quad.Value{quad.IRI("alice")}},
-				Properties: linkedql.PropertyPath{&Vertex{
-					Values: []quad.Value{quad.IRI("likes")},
-				}},
+				From: &Vertex{Values: []quad.Value{alice}},
+				Properties: linkedql.NewPropertyPath(&Vertex{
+					Values: []quad.Value{likes},
+				}),
 			},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "bob"},
+			map[string]string{"@id": string(bob)},
 		},
 	},
 	{
@@ -335,8 +343,8 @@ var testCases = []struct {
 			},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
-			map[string]string{"@id": "likes"},
+			map[string]string{"@id": string(alice)},
+			map[string]string{"@id": string(likes)},
 		},
 	},
 	{
@@ -344,10 +352,10 @@ var testCases = []struct {
 		data: singleQuadData,
 		query: &Visit{
 			From:       &Vertex{Values: []quad.Value{}},
-			Properties: linkedql.PropertyPath{&Vertex{Values: []quad.Value{quad.IRI("likes")}}},
+			Properties: linkedql.NewPropertyPath(linkedql.PropertyIRI(likes)),
 		},
 		results: []interface{}{
-			map[string]string{"@id": "bob"},
+			map[string]string{"@id": string(bob)},
 		},
 	},
 	{
@@ -357,7 +365,7 @@ var testCases = []struct {
 			From: &Vertex{Values: []quad.Value{}},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "likes"},
+			map[string]string{"@id": string(likes)},
 		},
 	},
 	{
@@ -366,10 +374,14 @@ var testCases = []struct {
 		query: &Select{
 			From: &Properties{
 				From:  &Vertex{Values: []quad.Value{}},
-				Names: []quad.IRI{quad.IRI("likes")},
+				Names: []quad.IRI{likes},
+			},
+		},
+		results: []interface{}{
+			map[string]interface{}{
+				string(likes): map[string]string{"@id": string(bob)},
 			},
 		},
-		results: []interface{}{map[string]interface{}{"likes": map[string]string{"@id": "bob"}}},
 	},
 	{
 		name: "ReversePropertyNamesAs",
@@ -377,10 +389,14 @@ var testCases = []struct {
 		query: &Select{
 			From: &ReversePropertyNamesAs{
 				From: &Vertex{Values: []quad.Value{}},
-				Tag:  "predicate",
+				Tag:  "property",
+			},
+		},
+		results: []interface{}{
+			map[string]interface{}{
+				"property": map[string]string{"@id": string(likes)},
 			},
 		},
-		results: []interface{}{map[string]interface{}{"predicate": map[string]string{"@id": "likes"}}},
 	},
 	{
 		name: "PropertyNamesAs",
@@ -388,10 +404,12 @@ var testCases = []struct {
 		query: &Select{
 			From: &PropertyNamesAs{
 				From: &Vertex{Values: []quad.Value{}},
-				Tag:  "predicate",
+				Tag:  "property",
 			},
 		},
-		results: []interface{}{map[string]interface{}{"predicate": map[string]string{"@id": "likes"}}},
+		results: []interface{}{map[string]interface{}{
+			"property": map[string]string{"@id": string(likes)},
+		}},
 	},
 	{
 		name: "ReverseProperties",
@@ -399,10 +417,12 @@ var testCases = []struct {
 		query: &Select{
 			From: &ReverseProperties{
 				From:  &Vertex{Values: []quad.Value{}},
-				Names: []quad.IRI{quad.IRI("likes")},
+				Names: []quad.IRI{likes},
 			},
 		},
-		results: []interface{}{map[string]interface{}{"likes": map[string]string{"@id": "alice"}}},
+		results: []interface{}{map[string]interface{}{
+			string(likes): map[string]string{"@id": string(alice)},
+		}},
 	},
 	{
 		name: "Skip",
@@ -414,7 +434,7 @@ var testCases = []struct {
 			},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "bob"},
+			map[string]string{"@id": string(bob)},
 		},
 	},
 	{
@@ -422,47 +442,46 @@ var testCases = []struct {
 		data: singleQuadData,
 		query: &Union{
 			From: &Vertex{
-				Values: []quad.Value{quad.IRI("alice")},
+				Values: []quad.Value{alice},
 			},
 			Steps: []linkedql.PathStep{
 				&Vertex{
-					Values: []quad.Value{quad.IRI("bob")},
+					Values: []quad.Value{bob},
 				},
 			},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
-			map[string]string{"@id": "bob"},
+			map[string]string{"@id": string(alice)},
+			map[string]string{"@id": string(bob)},
 		},
 	},
 	{
 		name: "SelectFirst",
 		data: singleQuadData,
 		query: &SelectFirst{
-			From: &As{
-				From: &Visit{
-					From: &As{
-						Name: "liker",
-						From: &Vertex{},
-					},
-					Properties: linkedql.PropertyPath{&Vertex{Values: []quad.Value{quad.IRI("likes")}}},
+			From: &Visit{
+				From: &As{
+					Name: string(liker),
+					From: &Vertex{},
 				},
-				Name: "liked",
+				Properties: linkedql.NewPropertyPath(linkedql.PropertyIRI(likes)),
 			},
 		},
-		results: []interface{}{map[string]interface{}{"liked": map[string]string{"@id": "bob"}, "liker": map[string]string{"@id": "alice"}}},
+		results: []interface{}{map[string]interface{}{
+			string(liker): map[string]string{"@id": string(alice)},
+		}},
 	},
 	{
 		name: "Unique",
 		data: singleQuadData,
 		query: &Unique{
 			From: &Vertex{
-				Values: []quad.Value{quad.IRI("alice"), quad.IRI("alice"), quad.IRI("bob")},
+				Values: []quad.Value{alice, alice, bob},
 			},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
-			map[string]string{"@id": "bob"},
+			map[string]string{"@id": string(alice)},
+			map[string]string{"@id": string(bob)},
 		},
 	},
 	{
@@ -472,159 +491,126 @@ var testCases = []struct {
 			From: &Vertex{},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "alice"},
-			map[string]string{"@id": "bob"},
-			map[string]string{"@id": "likes"},
+			map[string]string{"@id": string(alice)},
+			map[string]string{"@id": string(bob)},
+			map[string]string{"@id": string(likes)},
 		},
 	},
 	{
 		name: "Optional",
 		data: []quad.Quad{
-			quad.MakeIRI("alice", "likes", "bob", ""),
-			quad.MakeIRI("alice", "name", "Alice", ""),
-			quad.MakeIRI("bob", "name", "Bob", ""),
+			newQuad(alice, likes, bob, nil),
+			newQuad(alice, name, quad.String("Alice"), nil),
+			newQuad(bob, name, quad.String("Bob"), nil),
 		},
 		query: &Select{
 			From: &Optional{
 				From: &Properties{
 					From:  &Vertex{Values: []quad.Value{}},
-					Names: []quad.IRI{quad.IRI("name")},
+					Names: []quad.IRI{name},
 				},
 				Step: &Properties{
 					From:  &Placeholder{},
-					Names: []quad.IRI{quad.IRI("likes")},
+					Names: []quad.IRI{likes},
 				},
 			},
 		},
 		results: []interface{}{
 			map[string]interface{}{
-				"likes": map[string]string{"@id": "bob"},
-				"name":  map[string]string{"@id": "Alice"},
+				string(likes): map[string]string{"@id": string(bob)},
+				string(name):  "Alice",
 			},
 			map[string]interface{}{
-				"name": map[string]string{"@id": "Bob"},
+				string(name): "Bob",
 			},
 		},
 	},
 	{
 		name: "Where",
 		data: []quad.Quad{
-			quad.MakeIRI("alice", "likes", "bob", ""),
-			quad.MakeIRI("alice", "name", "Alice", ""),
-			quad.MakeIRI("bob", "name", "Bob", ""),
+			newQuad(alice, likes, bob, nil),
+			newQuad(alice, name, quad.String("Alice"), nil),
+			newQuad(bob, name, quad.String("Bob"), nil),
 		},
 		query: &Select{
-			From: &As{
-				From: &Where{
-					From: &Vertex{},
-					Steps: []linkedql.PathStep{
-						&As{
-							From: &Visit{
-								From: &Visit{
-									From:       &Placeholder{},
-									Properties: linkedql.PropertyPath{&Vertex{Values: []quad.Value{quad.IRI("likes")}}},
-								},
-								Properties: linkedql.PropertyPath{&Vertex{Values: []quad.Value{quad.IRI("name")}}},
-							},
-							Name: "likesName",
-						},
-						&As{
+			From: &Where{
+				From: &Vertex{},
+				Steps: []linkedql.PathStep{
+					&As{
+						From: &Visit{
 							From: &Visit{
 								From:       &Placeholder{},
-								Properties: linkedql.PropertyPath{&Vertex{Values: []quad.Value{quad.IRI("name")}}},
+								Properties: linkedql.NewPropertyPath(linkedql.PropertyIRI(likes)),
 							},
-							Name: "name",
+							Properties: linkedql.NewPropertyPath(linkedql.PropertyIRI(name)),
+						},
+						Name: string(likesName),
+					},
+					&As{
+						From: &Visit{
+							From:       &Placeholder{},
+							Properties: linkedql.NewPropertyPath(linkedql.PropertyIRI(name)),
 						},
+						Name: string(name),
 					},
 				},
-				Name: "person",
 			},
 		},
 		results: []interface{}{
 			map[string]interface{}{
-				"person":    map[string]string{"@id": "alice"},
-				"name":      map[string]string{"@id": "Alice"},
-				"likesName": map[string]string{"@id": "Bob"},
+				string(name):      "Alice",
+				string(likesName): "Bob",
 			},
 		},
 	},
 	{
 		name: "Documents",
 		data: []quad.Quad{
-			quad.MakeIRI("alice", "likes", "bob", ""),
-			quad.MakeIRI("alice", "name", "Alice", ""),
-			quad.MakeIRI("bob", "name", "Bob", ""),
-			quad.MakeIRI("bob", "likes", "alice", ""),
+			newQuad(alice, likes, bob, nil),
+			newQuad(alice, name, quad.String("Alice"), nil),
+			newQuad(bob, name, quad.String("Bob"), nil),
+			newQuad(bob, likes, alice, nil),
 		},
 		query: &Documents{
 			From: &Properties{
 				From:  &Vertex{Values: []quad.Value{}},
-				Names: []quad.IRI{quad.IRI("name"), quad.IRI("likes")},
+				Names: []quad.IRI{name, likes},
 			},
 		},
 		results: []interface{}{
 			map[string]interface{}{
-				"@id":   "alice",
-				"name":  []interface{}{map[string]string{"@id": "Alice"}},
-				"likes": []interface{}{map[string]string{"@id": "bob"}},
+				"@id":         string(alice),
+				string(name):  []interface{}{"Alice"},
+				string(likes): []interface{}{map[string]string{"@id": string(bob)}},
 			},
 			map[string]interface{}{
-				"@id":   "bob",
-				"name":  []interface{}{map[string]string{"@id": "Bob"}},
-				"likes": []interface{}{map[string]string{"@id": "alice"}},
+				"@id":         string(bob),
+				string(name):  []interface{}{"Bob"},
+				string(likes): []interface{}{map[string]string{"@id": string(alice)}},
 			},
 		},
 	},
 	{
 		name: "Context",
 		data: []quad.Quad{
-			quad.MakeIRI("http://example.org/alice", "http://example.org/likes", "http://example.org/bob", ""),
-			quad.MakeIRI("http://example.org/bob", "http://example.org/likes", "http://example.org/alice", ""),
+			newQuad(alice, likes, bob, nil),
+			newQuad(bob, likes, alice, nil),
 		},
 		query: &Context{
 			From: &Has{
 				From:     &Vertex{},
-				Property: linkedql.PropertyPath{linkedql.PropertyIRI("likes")},
-				Values:   []quad.Value{quad.IRI("bob")},
+				Property: linkedql.NewPropertyPath(linkedql.PropertyIRI("likes")),
+				Values:   []quad.Value{bob},
 			},
 			Rules: map[string]string{
-				"bob":   "http://example.org/bob",
-				"likes": "http://example.org/likes",
+				"bob":   string(bob),
+				"likes": string(likes),
 			},
 		},
 		results: []interface{}{
-			map[string]string{"@id": "http://example.org/alice"},
-		},
-	},
-	{
-		name: "Match @id",
-		data: []quad.Quad{
-			quad.MakeIRI("http://example.org/alice", "http://example.org/likes", "http://example.org/bob", ""),
-			quad.MakeIRI("http://example.org/bob", "http://example.org/likes", "http://example.org/alice", ""),
-		},
-		query: &Match{
-			From:    &Vertex{},
-			Pattern: linkedql.GraphPattern{"@id": "http://example.org/alice"},
-		},
-		results: []interface{}{
-			map[string]string{"@id": "http://example.org/alice"},
-		},
-	},
-	{
-		name: "Match property",
-		data: []quad.Quad{
-			quad.MakeIRI("http://example.org/alice", "http://example.org/likes", "http://example.org/bob", ""),
-			quad.MakeIRI("http://example.org/bob", "http://example.org/likes", "http://example.org/alice", ""),
-		},
-		query: &Match{
-			From:    &Vertex{},
-			Pattern: linkedql.GraphPattern{"http://example.org/likes": map[string]interface{}{"@id": "http://example.org/alice"}},
-		},
-		results: []interface{}{
-			map[string]string{"@id": "http://example.org/bob"},
+			map[string]string{"@id": string(alice)},
 		},
 	},
-	// FIXME(iddan): add test for match nested objects.
 }
 
 func TestLinkedQL(t *testing.T) {