good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
7bc40aa9
Commit
7bc40aa9
authored
10 years ago
by
Viktor Trón
Browse files
Options
Downloads
Patches
Plain Diff
jsre: remove assetpath using GOPATH from test
parent
7279a485
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jsre/jsre_test.go
+20
-21
20 additions, 21 deletions
jsre/jsre_test.go
with
20 additions
and
21 deletions
jsre/jsre_test.go
+
20
−
21
View file @
7bc40aa9
...
...
@@ -2,15 +2,11 @@ package jsre
import
(
"github.com/obscuren/otto"
"os"
"path"
"testing"
"github.com/ethereum/go-ethereum/ethutil"
)
var
defaultAssetPath
=
path
.
Join
(
os
.
Getenv
(
"GOPATH"
),
"src"
,
"github.com"
,
"ethereum"
,
"go-ethereum"
,
"cmd"
,
"mist"
,
"assets"
,
"ext"
)
type
testNativeObjectBinding
struct
{
toVal
func
(
interface
{})
otto
.
Value
}
...
...
@@ -42,20 +38,15 @@ func TestExec(t *testing.T) {
if
!
val
.
IsString
()
{
t
.
Errorf
(
"expected string value, got %v"
,
val
)
}
// this errors
err
=
jsre
.
Exec
(
path
.
Join
(
defaultAssetPath
,
"bignumber.min.js"
))
if
err
!=
nil
{
t
.
Errorf
(
"expected no error, got %v"
,
err
)
}
_
,
err
=
jsre
.
Run
(
"x = new BigNumber(123.4567);"
)
if
err
!=
nil
{
t
.
Errorf
(
"expected no error, got %v"
,
err
)
exp
:=
"testMsg"
got
,
_
:=
val
.
ToString
()
if
exp
!=
got
{
t
.
Errorf
(
"expected '%v', got '%v'"
,
exp
,
got
)
}
}
func
TestBind
(
t
*
testing
.
T
)
{
jsre
:=
New
(
defaultAssetPath
)
jsre
:=
New
(
"/tmp"
)
jsre
.
Bind
(
"no"
,
&
testNativeObjectBinding
{
jsre
.
ToVal
})
...
...
@@ -70,16 +61,24 @@ func TestBind(t *testing.T) {
t
.
Logf
(
"no: %v"
,
pp
)
}
func
Test
Require
(
t
*
testing
.
T
)
{
jsre
:=
New
(
defaultAssetPath
)
func
Test
LoadScript
(
t
*
testing
.
T
)
{
jsre
:=
New
(
"/tmp"
)
_
,
err
:=
jsre
.
Run
(
"x = new BigNumber(123.4567);"
)
if
err
==
nil
{
t
.
Errorf
(
"expected error, got nothing"
)
ethutil
.
WriteFile
(
"/tmp/test.js"
,
[]
byte
(
`msg = "testMsg"`
))
_
,
err
:=
jsre
.
Run
(
`loadScript("test.js")`
)
if
err
!=
nil
{
t
.
Errorf
(
"expected no error, got %v"
,
err
)
}
_
,
err
=
jsre
.
Run
(
`loadScript("bignumber.min.js"); x = new BigNumber(123.4567)`
)
val
,
err
:
=
jsre
.
Run
(
"msg"
)
if
err
!=
nil
{
t
.
Errorf
(
"expected no error, got %v"
,
err
)
}
if
!
val
.
IsString
()
{
t
.
Errorf
(
"expected string value, got %v"
,
val
)
}
exp
:=
"testMsg"
got
,
_
:=
val
.
ToString
()
if
exp
!=
got
{
t
.
Errorf
(
"expected '%v', got '%v'"
,
exp
,
got
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment