-
-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
189 changed files
with
4,608 additions
and
7,406 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
module github.com/MontFerret/ferret | ||
|
||
go 1.18 | ||
go 1.20 | ||
|
||
require ( | ||
github.com/PuerkitoBio/goquery v1.8.1 | ||
github.com/antchfx/htmlquery v1.3.0 | ||
github.com/antchfx/xpath v1.2.4 | ||
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1 | ||
github.com/antlr4-go/antlr/v4 v4.13.0 | ||
github.com/corpix/uarand v0.2.0 | ||
github.com/gobwas/glob v0.2.3 | ||
github.com/gorilla/css v1.0.0 | ||
github.com/jarcoal/httpmock v1.3.0 | ||
github.com/mafredri/cdp v0.34.0 | ||
github.com/jarcoal/httpmock v1.3.1 | ||
github.com/mafredri/cdp v0.34.1 | ||
github.com/pkg/errors v0.9.1 | ||
github.com/rs/zerolog v1.29.0 | ||
github.com/rs/zerolog v1.31.0 | ||
github.com/sethgrid/pester v1.2.0 | ||
github.com/smartystreets/goconvey v1.7.2 | ||
github.com/stretchr/testify v1.8.2 | ||
github.com/smartystreets/goconvey v1.8.1 | ||
github.com/stretchr/testify v1.8.4 | ||
github.com/wI2L/jettison v0.7.4 | ||
golang.org/x/net v0.8.0 | ||
golang.org/x/sync v0.1.0 | ||
golang.org/x/text v0.8.0 | ||
golang.org/x/net v0.15.0 | ||
golang.org/x/sync v0.3.0 | ||
golang.org/x/text v0.13.0 | ||
) | ||
|
||
require ( | ||
github.com/andybalholm/cascadia v1.3.1 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect | ||
github.com/gopherjs/gopherjs v1.17.2 // indirect | ||
github.com/gorilla/websocket v1.4.2 // indirect | ||
github.com/jtolds/gls v4.20.0+incompatible // indirect | ||
github.com/mattn/go-colorable v0.1.12 // indirect | ||
github.com/mattn/go-isatty v0.0.14 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.19 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/smartystreets/assertions v1.2.0 // indirect | ||
github.com/smarty/assertions v1.15.0 // indirect | ||
github.com/stretchr/objx v0.5.0 // indirect | ||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect | ||
golang.org/x/sys v0.6.0 // indirect | ||
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect | ||
golang.org/x/sys v0.12.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package compiler_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/smartystreets/goconvey/convey" | ||
|
||
"github.com/MontFerret/ferret/pkg/compiler" | ||
) | ||
|
||
func TestFor(t *testing.T) { | ||
RunUseCases(t, compiler.New(), []UseCase{ | ||
{ | ||
"FOR i IN 1..5 RETURN i", | ||
[]any{1, 2, 3, 4, 5}, | ||
ShouldEqualJSON, | ||
}, | ||
}) | ||
} |
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,19 +1,40 @@ | ||
package compiler_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/MontFerret/ferret/pkg/runtime" | ||
"github.com/MontFerret/ferret/pkg/runtime/core" | ||
"github.com/MontFerret/ferret/pkg/runtime/values" | ||
|
||
. "github.com/smartystreets/goconvey/convey" | ||
|
||
"github.com/MontFerret/ferret/pkg/compiler" | ||
) | ||
|
||
func TestForWhile(t *testing.T) { | ||
var counter int64 | ||
RunUseCases(t, compiler.New(), []UseCase{ | ||
//{ | ||
// "FOR i WHILE false RETURN i", | ||
// []any{}, | ||
// ShouldEqualJSON, | ||
//}, | ||
{ | ||
"FOR i WHILE false RETURN i", | ||
[]any{}, | ||
"FOR i WHILE UNTIL(5) RETURN i", | ||
[]any{0, 1, 2, 3, 4}, | ||
ShouldEqualJSON, | ||
}, | ||
}) | ||
}, runtime.WithFunctions(map[string]core.Function{ | ||
"UNTIL": func(ctx context.Context, args ...core.Value) (core.Value, error) { | ||
if counter < int64(values.ToInt(args[0])) { | ||
counter++ | ||
|
||
return values.True, nil | ||
} | ||
|
||
return values.False, nil | ||
}, | ||
})) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package compiler_test | ||
|
||
import ( | ||
"github.com/MontFerret/ferret/pkg/compiler" | ||
. "github.com/smartystreets/goconvey/convey" | ||
"testing" | ||
) | ||
|
||
func TestRange(t *testing.T) { | ||
RunUseCases(t, compiler.New(), []UseCase{ | ||
{ | ||
"RETURN 1..10", | ||
[]any{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, | ||
ShouldEqualJSON, | ||
}, | ||
{ | ||
` | ||
LET start = 1 | ||
LET end = 10 | ||
RETURN start..end | ||
`, | ||
[]any{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, | ||
ShouldEqualJSON, | ||
}, | ||
// { | ||
// ` | ||
//LET start = @start | ||
//LET end = @end | ||
//RETURN start..end | ||
//`, | ||
// []any{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, | ||
// ShouldEqualJSON, | ||
// }, | ||
}) | ||
} |
Oops, something went wrong.