Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
08c8cbee
Commit
08c8cbee
authored
Aug 23, 2018
by
0mkar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve string tests
parent
e64c9288
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
15 deletions
+16
-15
simple_string.sol
tests/examples_3/simple_string.sol
+1
-5
simple_string_test.sol
tests/examples_3/simple_string_test.sol
+6
-2
testRunner.js
tests/testRunner.js
+9
-8
No files found.
tests/examples_3/simple_string.sol
View file @
08c8cbee
...
@@ -3,11 +3,7 @@ contract SimpleString {
...
@@ -3,11 +3,7 @@ contract SimpleString {
string public storedData;
string public storedData;
function SimpleString() public {
function SimpleString() public {
storedData = "Hello";
storedData = "Hello world!";
}
function set(string x) public {
storedData = x;
}
}
function get() public view returns (string retVal) {
function get() public view returns (string retVal) {
...
...
tests/examples_3/simple_string_test.sol
View file @
08c8cbee
...
@@ -2,7 +2,7 @@ pragma solidity ^0.4.7;
...
@@ -2,7 +2,7 @@ pragma solidity ^0.4.7;
import "./tests.sol";
import "./tests.sol";
import "./simple_string.sol";
import "./simple_string.sol";
contract
My
Test {
contract
String
Test {
SimpleString foo;
SimpleString foo;
function beforeAll() {
function beforeAll() {
...
@@ -10,6 +10,10 @@ contract MyTest {
...
@@ -10,6 +10,10 @@ contract MyTest {
}
}
function initialValueShouldBeHello() public constant returns (bool) {
function initialValueShouldBeHello() public constant returns (bool) {
return Assert.equal(foo.get(), "Hello", "initial value is not correct");
return Assert.equal(foo.get(), "Hello world!", "initial value is not correct");
}
function valueShouldBeHelloWorld() public constant returns (bool) {
return Assert.equal(foo.get(), "Hello wordl!", "initial value is not correct");
}
}
}
}
tests/testRunner.js
View file @
08c8cbee
...
@@ -50,7 +50,7 @@ describe('testRunner', function () {
...
@@ -50,7 +50,7 @@ describe('testRunner', function () {
assert
.
equal
(
results
.
failureNum
,
2
)
assert
.
equal
(
results
.
failureNum
,
2
)
})
})
it
(
'should returns
3
messages'
,
function
()
{
it
(
'should returns
5
messages'
,
function
()
{
assert
.
deepEqual
(
tests
,
[
assert
.
deepEqual
(
tests
,
[
{
type
:
'contract'
,
value
:
'MyTest'
,
filename
:
'simple_storage_test.sol'
},
{
type
:
'contract'
,
value
:
'MyTest'
,
filename
:
'simple_storage_test.sol'
},
{
type
:
'testFailure'
,
value
:
'Should trigger one fail'
,
time
:
1
,
context
:
'MyTest'
,
errMsg
:
'the test 1 fails'
},
{
type
:
'testFailure'
,
value
:
'Should trigger one fail'
,
time
:
1
,
context
:
'MyTest'
,
errMsg
:
'the test 1 fails'
},
...
@@ -107,10 +107,10 @@ describe('testRunner', function () {
...
@@ -107,10 +107,10 @@ describe('testRunner', function () {
}
}
var
resultsCallback
=
function
(
_err
,
_results
)
{
var
resultsCallback
=
function
(
_err
,
_results
)
{
results
=
_results
results
=
_results
console
.
log
(
results
)
done
()
done
()
}
}
TestRunner
.
runTest
(
'MyTest'
,
contracts
.
MyTest
,
testCallback
,
resultsCallback
)
TestRunner
.
runTest
(
'StringTest'
,
contracts
.
StringTest
,
testCallback
,
resultsCallback
)
TestRunner
.
runTest
(
'StringTest2'
,
contracts
.
StringTest2
,
testCallback
,
resultsCallback
)
})
})
})
})
...
@@ -118,14 +118,15 @@ describe('testRunner', function () {
...
@@ -118,14 +118,15 @@ describe('testRunner', function () {
assert
.
equal
(
results
.
passingNum
,
1
)
assert
.
equal
(
results
.
passingNum
,
1
)
})
})
it
(
'should
0
failing tests'
,
function
()
{
it
(
'should
1
failing tests'
,
function
()
{
assert
.
equal
(
results
.
failureNum
,
0
)
assert
.
equal
(
results
.
failureNum
,
1
)
})
})
it
(
'should returns
2
messages'
,
function
()
{
it
(
'should returns
3
messages'
,
function
()
{
assert
.
deepEqual
(
tests
,
[
assert
.
deepEqual
(
tests
,
[
{
type
:
'contract'
,
value
:
'MyTest'
,
filename
:
'simple_string_test.sol'
},
{
type
:
'contract'
,
value
:
'StringTest'
,
filename
:
'simple_string_test.sol'
},
{
type
:
'testPass'
,
value
:
'Initial value should be hello'
,
time
:
1
,
context
:
'MyTest'
}
{
type
:
'testFailure'
,
value
:
'Value should be hello world'
,
time
:
1
,
context
:
'StringTest'
,
"errMsg"
:
"function returned false"
},
{
type
:
'testPass'
,
value
:
'Initial value should be hello'
,
time
:
1
,
context
:
'StringTest'
},
])
])
})
})
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment