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
42d31b4e
Commit
42d31b4e
authored
Aug 19, 2020
by
aniket-engg
Committed by
Aniket
Aug 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bool for equal and notEqual done
parent
a3c93934
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
12 deletions
+46
-12
tests.sol.ts
libs/remix-tests/sol/tests.sol.ts
+9
-2
assertionEvents.ts
libs/remix-tests/src/assertionEvents.ts
+4
-0
assert_equal_test.sol
libs/remix-tests/tests/examples_0/assert_equal_test.sol
+9
-0
assert_notEqual_test.sol
libs/remix-tests/tests/examples_0/assert_notEqual_test.sol
+9
-0
testRunner.spec.ts
libs/remix-tests/tests/testRunner.spec.ts
+15
-10
No files found.
libs/remix-tests/sol/tests.sol.ts
View file @
42d31b4e
...
@@ -22,6 +22,13 @@ library Assert {
...
@@ -22,6 +22,13 @@ library Assert {
int256 expected
int256 expected
);
);
event AssertionEventBool(
bool passed,
string message,
bool returned,
bool expected
);
function ok(bool a, string memory message) public returns (bool result) {
function ok(bool a, string memory message) public returns (bool result) {
result = a;
result = a;
emit AssertionEvent(result, message);
emit AssertionEvent(result, message);
...
@@ -39,7 +46,7 @@ library Assert {
...
@@ -39,7 +46,7 @@ library Assert {
function equal(bool a, bool b, string memory message) public returns (bool result) {
function equal(bool a, bool b, string memory message) public returns (bool result) {
result = (a == b);
result = (a == b);
emit AssertionEvent
(result, message
);
emit AssertionEvent
Bool(result, message, a, b
);
}
}
// TODO: only for certain versions of solc
// TODO: only for certain versions of solc
...
@@ -81,7 +88,7 @@ library Assert {
...
@@ -81,7 +88,7 @@ library Assert {
function notEqual(bool a, bool b, string memory message) public returns (bool result) {
function notEqual(bool a, bool b, string memory message) public returns (bool result) {
result = (a != b);
result = (a != b);
emit AssertionEvent
(result, message
);
emit AssertionEvent
Bool(result, message, a, b
);
}
}
// TODO: only for certain versions of solc
// TODO: only for certain versions of solc
...
...
libs/remix-tests/src/assertionEvents.ts
View file @
42d31b4e
...
@@ -10,6 +10,10 @@ const assertionEvents = [
...
@@ -10,6 +10,10 @@ const assertionEvents = [
{
{
name
:
'AssertionEventInt'
,
name
:
'AssertionEventInt'
,
params
:
[
'bool'
,
'string'
,
'int256'
,
'int256'
]
params
:
[
'bool'
,
'string'
,
'int256'
,
'int256'
]
},
{
name
:
'AssertionEventBool'
,
params
:
[
'bool'
,
'string'
,
'bool'
,
'bool'
]
}
}
]
]
...
...
libs/remix-tests/tests/examples_0/assert_equal_test.sol
View file @
42d31b4e
...
@@ -17,4 +17,12 @@ contract AssertEqualTest {
...
@@ -17,4 +17,12 @@ contract AssertEqualTest {
function equalIntFailTest() public {
function equalIntFailTest() public {
Assert.equal(-1, 2, "equalIntFailTest fails");
Assert.equal(-1, 2, "equalIntFailTest fails");
}
}
function equalBoolPassTest() public {
Assert.equal(true, true, "equalBoolPassTest passes");
}
function equalBoolFailTest() public {
Assert.equal(true, false, "equalBoolFailTest fails");
}
}
}
\ No newline at end of file
libs/remix-tests/tests/examples_0/assert_notEqual_test.sol
View file @
42d31b4e
...
@@ -9,6 +9,7 @@ contract AssertNotEqualTest {
...
@@ -9,6 +9,7 @@ contract AssertNotEqualTest {
function notEqualUintFailTest() public {
function notEqualUintFailTest() public {
Assert.notEqual(uint(1), uint(1), "notEqualUintFailTest fails");
Assert.notEqual(uint(1), uint(1), "notEqualUintFailTest fails");
}
}
function notEqualIntPassTest() public {
function notEqualIntPassTest() public {
Assert.notEqual(1, -1, "notEqualIntPassTest passes");
Assert.notEqual(1, -1, "notEqualIntPassTest passes");
}
}
...
@@ -16,4 +17,12 @@ contract AssertNotEqualTest {
...
@@ -16,4 +17,12 @@ contract AssertNotEqualTest {
function notEqualIntFailTest() public {
function notEqualIntFailTest() public {
Assert.notEqual(-2, -2, "notEqualIntFailTest fails");
Assert.notEqual(-2, -2, "notEqualIntFailTest fails");
}
}
function notEqualBoolPassTest() public {
Assert.notEqual(true, false, "notEqualBoolPassTest passes");
}
function notEqualBoolFailTest() public {
Assert.notEqual(true, true, "notEqualBoolFailTest fails");
}
}
}
libs/remix-tests/tests/testRunner.spec.ts
View file @
42d31b4e
...
@@ -76,6 +76,7 @@ async function compileAndDeploy(filename: string, callback: Function) {
...
@@ -76,6 +76,7 @@ async function compileAndDeploy(filename: string, callback: Function) {
})
})
}
}
// Use `export NODE_OPTIONS="--max-old-space-size=2048"` if there is a JavaScript heap out of memory issue
describe
(
'testRunner'
,
()
=>
{
describe
(
'testRunner'
,
()
=>
{
let
tests
:
any
[]
=
[],
results
:
ResultsInterface
;
let
tests
:
any
[]
=
[],
results
:
ResultsInterface
;
...
@@ -142,12 +143,12 @@ describe('testRunner', () => {
...
@@ -142,12 +143,12 @@ describe('testRunner', () => {
afterAll
(()
=>
{
tests
=
[]
})
afterAll
(()
=>
{
tests
=
[]
})
it
(
'should have
2
passing test'
,
()
=>
{
it
(
'should have
3
passing test'
,
()
=>
{
assert
.
equal
(
results
.
passingNum
,
2
)
assert
.
equal
(
results
.
passingNum
,
3
)
})
})
it
(
'should have
2
failing test'
,
()
=>
{
it
(
'should have
3
failing test'
,
()
=>
{
assert
.
equal
(
results
.
failureNum
,
2
)
assert
.
equal
(
results
.
failureNum
,
3
)
})
})
it
(
'should return'
,
()
=>
{
it
(
'should return'
,
()
=>
{
...
@@ -157,7 +158,9 @@ describe('testRunner', () => {
...
@@ -157,7 +158,9 @@ describe('testRunner', () => {
{
type
:
'testPass'
,
value
:
'Equal uint pass test'
,
context
:
'AssertEqualTest'
},
{
type
:
'testPass'
,
value
:
'Equal uint pass test'
,
context
:
'AssertEqualTest'
},
{
type
:
'testFailure'
,
value
:
'Equal uint fail test'
,
errMsg
:
'equalUintFailTest fails'
,
context
:
'AssertEqualTest'
,
expected
:
'2'
,
returned
:
'1'
},
{
type
:
'testFailure'
,
value
:
'Equal uint fail test'
,
errMsg
:
'equalUintFailTest fails'
,
context
:
'AssertEqualTest'
,
expected
:
'2'
,
returned
:
'1'
},
{
type
:
'testPass'
,
value
:
'Equal int pass test'
,
context
:
'AssertEqualTest'
},
{
type
:
'testPass'
,
value
:
'Equal int pass test'
,
context
:
'AssertEqualTest'
},
{
type
:
'testFailure'
,
value
:
'Equal int fail test'
,
errMsg
:
'equalIntFailTest fails'
,
context
:
'AssertEqualTest'
,
expected
:
'2'
,
returned
:
'-1'
}
{
type
:
'testFailure'
,
value
:
'Equal int fail test'
,
errMsg
:
'equalIntFailTest fails'
,
context
:
'AssertEqualTest'
,
expected
:
'2'
,
returned
:
'-1'
},
{
type
:
'testPass'
,
value
:
'Equal bool pass test'
,
context
:
'AssertEqualTest'
},
{
type
:
'testFailure'
,
value
:
'Equal bool fail test'
,
errMsg
:
'equalBoolFailTest fails'
,
context
:
'AssertEqualTest'
,
expected
:
false
,
returned
:
true
}
],
[
'time'
])
],
[
'time'
])
})
})
})
})
...
@@ -173,12 +176,12 @@ describe('testRunner', () => {
...
@@ -173,12 +176,12 @@ describe('testRunner', () => {
afterAll
(()
=>
{
tests
=
[]
})
afterAll
(()
=>
{
tests
=
[]
})
it
(
'should have
2
passing test'
,
()
=>
{
it
(
'should have
3
passing test'
,
()
=>
{
assert
.
equal
(
results
.
passingNum
,
2
)
assert
.
equal
(
results
.
passingNum
,
3
)
})
})
it
(
'should have
2
failing test'
,
()
=>
{
it
(
'should have
3
failing test'
,
()
=>
{
assert
.
equal
(
results
.
failureNum
,
2
)
assert
.
equal
(
results
.
failureNum
,
3
)
})
})
it
(
'should return'
,
()
=>
{
it
(
'should return'
,
()
=>
{
...
@@ -188,7 +191,9 @@ describe('testRunner', () => {
...
@@ -188,7 +191,9 @@ describe('testRunner', () => {
{
type
:
'testPass'
,
value
:
'Not equal uint pass test'
,
context
:
'AssertNotEqualTest'
},
{
type
:
'testPass'
,
value
:
'Not equal uint pass test'
,
context
:
'AssertNotEqualTest'
},
{
type
:
'testFailure'
,
value
:
'Not equal uint fail test'
,
errMsg
:
'notEqualUintFailTest fails'
,
context
:
'AssertNotEqualTest'
,
expected
:
'1'
,
returned
:
'1'
},
{
type
:
'testFailure'
,
value
:
'Not equal uint fail test'
,
errMsg
:
'notEqualUintFailTest fails'
,
context
:
'AssertNotEqualTest'
,
expected
:
'1'
,
returned
:
'1'
},
{
type
:
'testPass'
,
value
:
'Not equal int pass test'
,
context
:
'AssertNotEqualTest'
},
{
type
:
'testPass'
,
value
:
'Not equal int pass test'
,
context
:
'AssertNotEqualTest'
},
{
type
:
'testFailure'
,
value
:
'Not equal int fail test'
,
errMsg
:
'notEqualIntFailTest fails'
,
context
:
'AssertNotEqualTest'
,
expected
:
'-2'
,
returned
:
'-2'
}
{
type
:
'testFailure'
,
value
:
'Not equal int fail test'
,
errMsg
:
'notEqualIntFailTest fails'
,
context
:
'AssertNotEqualTest'
,
expected
:
'-2'
,
returned
:
'-2'
},
{
type
:
'testPass'
,
value
:
'Not equal bool pass test'
,
context
:
'AssertNotEqualTest'
},
{
type
:
'testFailure'
,
value
:
'Not equal bool fail test'
,
errMsg
:
'notEqualBoolFailTest fails'
,
context
:
'AssertNotEqualTest'
,
expected
:
true
,
returned
:
true
}
],
[
'time'
])
],
[
'time'
])
})
})
})
})
...
...
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