Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 8d1ecc3

Browse files
author
Juanjo Alvarez
committed
Added (nonworking) test
Signed-off-by: Juanjo Alvarez <[email protected]>
1 parent 9174c5b commit 8d1ecc3

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

driver/normalizer/normalizer.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ func (op opJoinNamesArray) Check(st *State, n nodes.Node) (bool, error) {
7474
var qual = uast.QualifiedIdentifier{}
7575

7676
for _, t := range tokens {
77-
//id := Obj(nil)
7877
id := uast.Identifier{Name: t}
7978
qual.Names = append(qual.Names, id)
8079
}
Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
11
package normalizer
22

33
import (
4-
"os/exec"
4+
"fmt"
5+
"github.com/stretchr/testify/require"
6+
"gopkg.in/bblfsh/sdk.v2/uast/nodes"
57
"testing"
6-
"time"
7-
8-
"github.com/bblfsh/sdk"
98

10-
"github.com/stretchr/testify/require"
9+
. "gopkg.in/bblfsh/sdk.v2/uast/transformer"
1110
)
1211

13-
func TestNativeBinary(t *testing.T) {
14-
r := require.New(t)
12+
func TestOpJoinNamesArray(t *testing.T) {
13+
op := opJoinNamesArray{Var("x")}
14+
st := NewState()
15+
n1 := nodes.String("a::b::c")
16+
fmt.Println(string(n1) == "a::b::c") // true
17+
18+
res, err := op.Check(st, n1)
19+
require.NoError(t, err)
20+
require.True(t, res)
1521

16-
cmd := exec.Command(sdk.NativeBinTest)
17-
err := cmd.Start()
18-
r.Nil(err)
22+
n2, ok := st.GetVar("x")
23+
require.True(t, ok)
24+
require.NotNil(t, n2)
25+
//fmt.Println(n2) // prints the QualifiedIdentifier correctly
1926

20-
time.Sleep(time.Second)
21-
err = cmd.Process.Kill()
22-
r.Nil(err)
27+
n3, err := op.Construct(st, nil)
28+
require.NotNil(t, n3)
29+
require.NoError(t, err)
30+
fmt.Println("XXX n3")
31+
fmt.Println(n3)
32+
x, ok := n3.(nodes.String)
33+
require.True(t, ok)
34+
fmt.Println("XXX should be String")
35+
fmt.Println(x) // empty
36+
fmt.Println(string(x))
37+
fmt.Println(string(x) == "a::b::c") // false
2338
}

0 commit comments

Comments
 (0)