Merge pull request #1312 from ethereum/update-unit-tests

update remix-tests unit tests
pull/5370/head
Omkara 5 years ago committed by GitHub
commit c331c12e44
  1. 2420
      remix-tests/package-lock.json
  2. 16
      remix-tests/tests/examples_1/simple_storage_test.sol
  3. 11
      remix-tests/tests/examples_2/simple_storage_test.sol
  4. 8
      remix-tests/tests/examples_3/simple_string_test.sol
  5. 27
      remix-tests/tests/testRunner.ts

File diff suppressed because it is too large Load Diff

@ -8,22 +8,20 @@ contract MyTest {
foo = new SimpleStorage();
}
function initialValueShouldBe100() public view returns (bool) {
//return Assert.equal(foo.get(), 100, "initial value is not correct");
return foo.get() == 100;
function initialValueShouldBe100() public returns (bool) {
return Assert.equal(foo.get(), 100, "initial value is not correct");
}
function initialValueShouldBe200() public view returns (bool) {
//return Assert.equal(foo.get(), 200, "initial value is not correct");
return foo.get() == 200;
function initialValueShouldNotBe200() public returns (bool) {
return Assert.notEqual(foo.get(), 200, "initial value is not correct");
}
function shouldTriggerOneFail() public {
Assert.equal(uint(1), uint(2), "the test 1 fails");
Assert.equal(uint(1), uint(2), "the test 2 fails");
Assert.equal(uint(1), uint(2), "uint test 1 fails");
Assert.notEqual(uint(1), uint(2), "uint test 2 passes");
}
function shouldTriggerOnePass() public {
Assert.equal(uint(1), uint(1), "the test 3 fails");
Assert.equal(uint(1), uint(1), "uint test 3 passes");
}
}

@ -13,14 +13,11 @@ contract MyTest {
i += 1;
}
function initialValueShouldBe100() public view returns (bool) {
//return Assert.equal(foo.get(), 100, "initial value is not correct");
return foo.get() == 100;
function initialValueShouldBe200() public returns (bool) {
return Assert.equal(foo.get(), 200, "initial value is not correct");
}
function initialValueShouldBe200() public view returns (bool) {
//return Assert.equal(foo.get(), 200, "initial value is not correct");
return foo.get() == 200;
function valueShouldBe100() public returns (bool) {
return Assert.equal(foo.get(), 100, "value is not correct after first execution");
}
}

@ -8,15 +8,11 @@ contract StringTest {
foo = new SimpleString();
}
function initialValueShouldBeHello() public returns (bool) {
function initialValueShouldBeHelloWorld() public returns (bool) {
return Assert.equal(foo.get(), "Hello world!", "initial value is not correct");
}
function valueShouldNotBeHelloWordl() public returns (bool) {
return Assert.notEqual(foo.get(), "Hello wordl!", "value should not be hello world");
}
function valueShouldBeHelloWorld() public returns (bool) {
return Assert.equal(foo.get(), "Hello wordl!", "initial value is not correct");
return Assert.notEqual(foo.get(), "Hello wordl!", "value should not be hello wordl");
}
}

@ -108,23 +108,23 @@ describe('testRunner', () => {
after(() => { tests = [] })
it('should 1 passing test', function () {
assert.equal(results.passingNum, 2)
it('should have 3 passing test', function () {
assert.equal(results.passingNum, 3)
})
it('should 1 failing test', function () {
assert.equal(results.failureNum, 2)
it('should have 1 failing test', function () {
assert.equal(results.failureNum, 1)
})
it('should return 6 messages', function () {
deepEqualExcluding(tests, [
{ type: 'accountList', value: accounts },
{ type: 'contract', value: 'MyTest', filename: 'tests/examples_1/simple_storage_test.sol' },
{ type: 'testFailure', value: 'Should trigger one fail', context: 'MyTest', errMsg: 'the test 1 fails' },
{ type: 'testPass', value: 'Initial value should not be200', context: 'MyTest' },
{ type: 'testFailure', value: 'Should trigger one fail', errMsg: 'uint test 1 fails', context: 'MyTest' },
{ type: 'testPass', value: 'Should trigger one pass', context: 'MyTest' },
{ type: 'testPass', value: 'Initial value should be100', context: 'MyTest' },
{ type: 'testFailure', value: 'Initial value should be200', context: 'MyTest', errMsg: 'function returned false' }
], ['time'])
{ type: 'testPass', value: 'Initial value should be100', context: 'MyTest' }
], ['time', 'value'])
})
})
@ -139,7 +139,7 @@ describe('testRunner', () => {
after(() => { tests = [] })
it('should 2 passing tests', function () {
it('should have 2 passing tests', function () {
assert.equal(results.passingNum, 2)
})
@ -151,7 +151,7 @@ describe('testRunner', () => {
deepEqualExcluding(tests, [
{ type: 'accountList', value: accounts },
{ type: 'contract', value: 'MyTest', filename: 'tests/examples_2/simple_storage_test.sol' },
{ type: 'testPass', value: 'Initial value should be100', context: 'MyTest' },
{ type: 'testPass', value: 'Value should be100', context: 'MyTest' },
{ type: 'testPass', value: 'Initial value should be200', context: 'MyTest' }
], ['time'])
})
@ -173,17 +173,12 @@ describe('testRunner', () => {
assert.equal(results.passingNum, 2)
})
it('should 1 failing tests', function () {
assert.equal(results.failureNum, 1)
})
it('should return 4 messages', function () {
deepEqualExcluding(tests, [
{ type: 'accountList', value: accounts },
{ type: 'contract', value: 'StringTest', filename: 'tests/examples_3/simple_string_test.sol' },
{ type: 'testFailure', value: 'Value should be hello world', context: 'StringTest', "errMsg": "initial value is not correct" },
{ type: 'testPass', value: 'Value should not be hello wordl', context: 'StringTest' },
{ type: 'testPass', value: 'Initial value should be hello', context: 'StringTest' },
{ type: 'testPass', value: 'Initial value should be hello world', context: 'StringTest' }
], ['time'])
})
})

Loading…
Cancel
Save