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
2e950d23
Commit
2e950d23
authored
Sep 01, 2018
by
0mkar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename to number test. Add 2^3 = 8 combinations of uint & int tests.
parent
555647c7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
22 deletions
+64
-22
tests.sol.js
remix-tests/sol/tests.sol.js
+21
-2
integer_test.sol
remix-tests/tests/integer/integer_test.sol
+0
-15
number_test.sol
remix-tests/tests/number/number_test.sol
+38
-0
testRunner.js
remix-tests/tests/testRunner.js
+5
-5
No files found.
remix-tests/sol/tests.sol.js
View file @
2e950d23
...
@@ -110,7 +110,7 @@ library Assert {
...
@@ -110,7 +110,7 @@ library Assert {
// TODO: safely compare between uint and int
// TODO: safely compare between uint and int
function greaterThan(uint a, int b, string message) public constant returns (bool result) {
function greaterThan(uint a, int b, string message) public constant returns (bool result) {
if(b < int(0)) {
if(b < int(0)) {
// int is negative
a
always greater
// int is negative
uint "a"
always greater
result = true;
result = true;
} else {
} else {
result = (a > uint(b));
result = (a > uint(b));
...
@@ -119,7 +119,7 @@ library Assert {
...
@@ -119,7 +119,7 @@ library Assert {
}
}
function greaterThan(int a, uint b, string message) public constant returns (bool result) {
function greaterThan(int a, uint b, string message) public constant returns (bool result) {
if(a < int(0)) {
if(a < int(0)) {
// int is negative
a
always greater
// int is negative
uint "b"
always greater
result = false;
result = false;
} else {
} else {
result = (uint(a) > b);
result = (uint(a) > b);
...
@@ -137,5 +137,24 @@ library Assert {
...
@@ -137,5 +137,24 @@ library Assert {
emit AssertionEvent(result, message);
emit AssertionEvent(result, message);
}
}
// TODO: safely compare between uint and int
// TODO: safely compare between uint and int
function lesserThan(uint a, int b, string message) public constant returns (bool result) {
if(b < int(0)) {
// int is negative int "b" always lesser
result = false;
} else {
result = (a < uint(b));
}
emit AssertionEvent(result, message);
}
function lesserThan(int a, uint b, string message) public constant returns (bool result) {
if(a < int(0)) {
// int is negative int "a" always lesser
result = true;
} else {
result = (uint(a) < b);
}
emit AssertionEvent(result, message);
}
}
}
`
`
remix-tests/tests/integer/integer_test.sol
deleted
100644 → 0
View file @
555647c7
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/number/number_test.sol
0 → 100644
View file @
2e950d23
pragma solidity ^0.4.24;
contract IntegerTest {
// GREATER THAN [>] tests
function _2_shouldBeGreaterThan_1() public constant returns (bool) {
return Assert.greaterThan(uint(2), uint(1), "2 is greater than 1");
}
function _0_shouldBeGreaterThan_neg_1() public constant returns (bool) {
return Assert.greaterThan(uint(0), int(-1), "0 is greater than -1");
}
function _neg_1_shouldNotBeGreaterThan_1() public constant returns (bool) {
return Assert.greaterThan(int(-1), uint(1), "-1 is not greater than 1");
}
function _1_shouldBeGreaterThan_neg_1() public constant returns (bool) {
return Assert.greaterThan(uint(1), int(-1), "1 is greater than -1");
}
// LESSER THAN [<] tests
function _1_shouldBeLesserThan_2() public constant returns (bool) {
return Assert.lesserThan(uint(1), uint(2), "1 is lesser than 2");
}
function _neg_1_shouldBeLesserThan_0() public constant returns (bool) {
return Assert.lesserThan(int(-1), uint(0), "-1 is lesser than 0");
}
function _neg_2_shouldBeLesserThan_neg_1() public constant returns (bool) {
return Assert.lesserThan(int(-2), int(-1), "-2 is lesser than -1");
}
function _0_shouldNotBeLesserThan_neg_1() public constant returns (bool) {
return Assert.lesserThan(uint(0), int(-1), "0 is not lesser than -1");
}
}
remix-tests/tests/testRunner.js
View file @
2e950d23
...
@@ -134,7 +134,7 @@ describe('testRunner', function () {
...
@@ -134,7 +134,7 @@ describe('testRunner', function () {
// Test signed/unsigned integer weight
// Test signed/unsigned integer weight
describe
(
'test number weight'
,
function
()
{
describe
(
'test number weight'
,
function
()
{
let
filename
=
'tests/
integer/integ
er_test.sol'
let
filename
=
'tests/
number/numb
er_test.sol'
let
tests
=
[],
results
=
{}
let
tests
=
[],
results
=
{}
before
(
function
(
done
)
{
before
(
function
(
done
)
{
...
@@ -150,11 +150,11 @@ describe('testRunner', function () {
...
@@ -150,11 +150,11 @@ describe('testRunner', function () {
})
})
})
})
it
(
'should have
2
passing tests'
,
function
()
{
it
(
'should have
6
passing tests'
,
function
()
{
assert
.
equal
(
results
.
passingNum
,
2
)
assert
.
equal
(
results
.
passingNum
,
6
)
})
})
it
(
'should have
1
failing tests'
,
function
()
{
it
(
'should have
2
failing tests'
,
function
()
{
assert
.
equal
(
results
.
failureNum
,
1
)
assert
.
equal
(
results
.
failureNum
,
2
)
})
})
})
})
})
})
...
...
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