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
2a233ada
Commit
2a233ada
authored
Sep 01, 2018
by
0mkar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add number weight tests
parent
c7d02259
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
2 deletions
+83
-2
tests.sol.js
remix-tests/sol/tests.sol.js
+40
-0
integer_test.sol
remix-tests/tests/integer/integer_test.sol
+15
-0
testRunner.js
remix-tests/tests/testRunner.js
+28
-2
No files found.
remix-tests/sol/tests.sol.js
View file @
2a233ada
...
@@ -97,5 +97,45 @@ library Assert {
...
@@ -97,5 +97,45 @@ library Assert {
AssertionEvent(result, message);
AssertionEvent(result, message);
}
}
/*----------------- Greater than --------------------*/
function greaterThan(uint a, uint b, string message) public constant returns (bool result) {
result = (a > b);
emit AssertionEvent(result, message);
}
function greaterThan(int a, int b, string message) public constant returns (bool result) {
result = (a > b);
emit AssertionEvent(result, message);
}
// TODO: safely compare between uint and int
function greaterThan(uint a, int b, string message) public constant returns (bool result) {
if(b < int(0)) {
// int is negative a always greater
result = true;
} else {
result = (a > uint(b));
}
emit AssertionEvent(result, message);
}
function greaterThan(int a, uint b, string message) public constant returns (bool result) {
if(a < int(0)) {
// int is negative a always greater
result = false;
} else {
result = (uint(a) > b);
}
emit AssertionEvent(result, message);
}
/*----------------- Lesser than --------------------*/
function lesserThan(uint a, uint b, string message) public constant returns (bool result) {
result = (a < b);
emit AssertionEvent(result, message);
}
function lesserThan(int a, int b, string message) public constant returns (bool result) {
result = (a < b);
emit AssertionEvent(result, message);
}
// TODO: safely compare between uint and int
}
}
`
`
remix-tests/tests/integer/integer_test.sol
0 → 100644
View file @
2a233ada
pragma solidity ^0.4.24;
contract IntegerTest {
function _2_shouldBeGreaterThan_1() public constant returns (bool) {
return Assert.greaterThan(uint(2), uint(1), "2 is not greater than 1");
}
function _2_shouldBeGreaterThan_neg_1() public constant returns (bool) {
return Assert.greaterThan(uint(2), int(-1), "2 is not greater than -1");
}
function _neg_1_shouldNotBeGreaterThan_2() public constant returns (bool) {
return Assert.greaterThan(int(-1), uint(2), "-1 is not greater than 2");
}
}
remix-tests/tests/testRunner.js
View file @
2a233ada
...
@@ -95,8 +95,8 @@ describe('testRunner', function () {
...
@@ -95,8 +95,8 @@ describe('testRunner', function () {
})
})
})
})
// Test string
comparision
// Test string
equality
describe
(
'test
with beforeAll
'
,
function
()
{
describe
(
'test
string equality
'
,
function
()
{
let
filename
=
'tests/examples_3/simple_string_test.sol'
let
filename
=
'tests/examples_3/simple_string_test.sol'
let
tests
=
[],
results
=
{}
let
tests
=
[],
results
=
{}
...
@@ -131,5 +131,31 @@ describe('testRunner', function () {
...
@@ -131,5 +131,31 @@ describe('testRunner', function () {
])
])
})
})
})
})
// Test signed/unsigned integer weight
describe
(
'test number weight'
,
function
()
{
let
filename
=
'tests/integer/integer_test.sol'
let
tests
=
[],
results
=
{}
before
(
function
(
done
)
{
compileAndDeploy
(
filename
,
function
(
_err
,
contracts
)
{
var
testCallback
=
function
(
test
)
{
tests
.
push
(
test
)
}
var
resultsCallback
=
function
(
_err
,
_results
)
{
results
=
_results
done
()
}
TestRunner
.
runTest
(
'IntegerTest'
,
contracts
.
IntegerTest
,
testCallback
,
resultsCallback
)
})
})
it
(
'should have 2 passing tests'
,
function
()
{
assert
.
equal
(
results
.
passingNum
,
2
)
})
it
(
'should have 1 failing tests'
,
function
()
{
assert
.
equal
(
results
.
failureNum
,
1
)
})
})
})
})
})
})
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