diff --git a/.gitignore b/.gitignore index 68f8dbe9a6..eddf24d1ff 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ docs/_build package-lock.json .DS_Store .tern-port +TODO +soljson.js diff --git a/.travis.yml b/.travis.yml index 5fd298c5b5..16fb9517ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ env: - TEST_DIR=remix-lib - TEST_DIR=remix-solidity - TEST_DIR=remix-debug + - TEST_DIR=remix-tests script: - cd $TEST_DIR && npm install && npm test deploy: @@ -15,4 +16,3 @@ deploy: branch: master condition: $TEST_DIR = remix-debugger cache: false - diff --git a/remix-tests/LICENSE.md b/remix-tests/LICENSE.md new file mode 100644 index 0000000000..27926b8b91 --- /dev/null +++ b/remix-tests/LICENSE.md @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2018 Remix Team + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/remix-tests/README.md b/remix-tests/README.md new file mode 100644 index 0000000000..3a41926ce0 --- /dev/null +++ b/remix-tests/README.md @@ -0,0 +1,118 @@ +[![Build Status](https://travis-ci.org/ethereum/remix-tests.svg?branch=master)](https://travis-ci.org/ethereum/remix-tests) + +Remix-Tests +--- + +> Tests for the Ethereum tool suite [Remix](https://github.com/ethereum/remix) + +### Installation + +`npm -g install remix-tests` + +### Test structure + +Example test file: +```Javascript +pragma solidity ^0.4.7; +import "remix_tests.sol"; // injected by remix-tests +import "./simple_storage.sol"; + +contract MyTest { + SimpleStorage foo; + uint i = 0; + + function beforeAll() { + foo = new SimpleStorage(); + } + + function beforeEach() { + if (i == 1) { + foo.set(200); + } + i += 1; + } + + function initialValueShouldBe100() public { + Assert.equal(foo.get(), 100, "initial value is not correct"); + } + + function initialValueShouldBe200() public constant returns { + return Assert.equal(foo.get(), 200, "initial value is not correct"); + } + +} +``` + +Available special functions: +* `beforeEach` - runs before each test +* `beforeAll` - runs before all tests + +#### Assert library + +Available functions: +`Assert.ok(value, message)` +`Assert.equal(value1, value2, message)` +`Assert.notEqual(value1, value2, message)` + +supported values currently are: `bool` `uint` `int` `address` `bytes32` + +### Command Line + +Remix-Tests will assume the tests will files whose name end with "_test.sol". e.g `simple_storage_test.sol` + +Usage: + +* A directory with tests files `remix-tests examples/` +* A test file `remix-tests examples/simple_storage_test.sol` + +### Library + +Importing the library: +```Javascript +const RemixTests = require('remix-tests'); +``` + +Running a single test object: +```Javascript +remixTests.runTest(contractName, contractObj, testCallback, resultsCallback) +``` +params: +`testName` - `string` name of the test +`testObj` - web3.js 1.0 contract instance of the test +`testCallback(object)` - called each time there is a test event. 3 possible type of objects: +* `{ type: 'contract', value: '', filename: '' }` +* `{ type: 'testPass', value: '', time: