Skip to content

Commit

Permalink
(temporarily) change import path
Browse files Browse the repository at this point in the history
until I can fix the repo name
  • Loading branch information
guregu committed Aug 8, 2022
1 parent 3336451 commit d953dbe
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# trealla-go [![GoDoc](https://godoc.org/github.com/guregu/trealla-go?status.svg)](https://godoc.org/github.com/guregu/trealla-go)
`import trealla "github.com/guregu/trealla-go"`
# trealla-go [![GoDoc](https://godoc.org/github.com/trealla-prolog/trealla-go?status.svg)](https://godoc.org/github.com/trealla-prolog/trealla-go)
`import trealla "github.com/trealla-prolog/trealla-go"`

(Note: package import path will change soon.)

Prolog interface for Go using [Trealla Prolog](https://github.com/trealla-prolog/trealla) and [Wasmer](https://github.com/wasmerio/wasmer-go).
It's pretty fast. Not as fast as native Trealla, but pretty dang fast (2-5x slower than native).
Expand All @@ -20,7 +22,7 @@ This library uses WebAssembly to run Trealla, executing Prolog queries in an iso

```go

import trealla "github.com/guregu/trealla-go"
import trealla "github.com/trealla-prolog/trealla-go"

func main() {
// load the interpreter and (optionally) grant access to the current directory
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/guregu/trealla-go
module github.com/trealla-prolog/trealla-go

go 1.18

Expand Down
30 changes: 16 additions & 14 deletions prolog_test.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
package trealla
package trealla_test

import (
"context"
"reflect"
"testing"

trealla "github.com/trealla-prolog/trealla-go"
)

func TestQuery(t *testing.T) {
pl, err := New(WithPreopenDir("testdata"))
pl, err := trealla.New(trealla.WithPreopenDir("testdata"))
if err != nil {
t.Fatal(err)
}

tests := []struct {
name string
want Answer
want trealla.Answer
}{
{
name: "true/0",
want: Answer{
want: trealla.Answer{
Query: `true.`,
Result: "success",
Answers: []Solution{{}},
Answers: []trealla.Solution{{}},
},
},
{
name: "member/2",
want: Answer{
want: trealla.Answer{
Query: `member(X, [1,foo(bar),4.2,"baz",'boop']).`,
Result: "success",
Answers: []Solution{
Answers: []trealla.Solution{
{"X": int64(1)},
{"X": Compound{Functor: "foo", Args: []Term{"bar"}}},
{"X": trealla.Compound{Functor: "foo", Args: []trealla.Term{"bar"}}},
{"X": 4.2},
{"X": "baz"},
{"X": "boop"},
Expand All @@ -40,17 +42,17 @@ func TestQuery(t *testing.T) {
},
{
name: "false/0",
want: Answer{
want: trealla.Answer{
Query: `false.`,
Result: "failure",
},
},
{
name: "tak",
want: Answer{
want: trealla.Answer{
Query: "consult('testdata/tak'), run",
Result: "success",
Answers: []Solution{{}},
Answers: []trealla.Solution{{}},
Output: "'<https://josd.github.io/eye/ns#tak>'([34,13,8],13).\n",
},
},
Expand All @@ -72,7 +74,7 @@ func TestQuery(t *testing.T) {
}

func TestThrow(t *testing.T) {
pl, err := New(WithPreopenDir("testdata"))
pl, err := trealla.New(trealla.WithPreopenDir("testdata"))
if err != nil {
t.Fatal(err)
}
Expand All @@ -84,8 +86,8 @@ func TestThrow(t *testing.T) {
t.Fatal(err)
}

if ans.Result != ResultError {
t.Error("unexpected result. want:", ResultError, "got:", ans.Result)
if ans.Result != trealla.ResultError {
t.Error("unexpected result. want:", trealla.ResultError, "got:", ans.Result)
}

if ans.Error != "ball" {
Expand Down

0 comments on commit d953dbe

Please sign in to comment.