diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-10 21:35:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-10 21:35:13 +0800 |
commit | 6c22594882c94146519ec6e3b24d558127bd092c (patch) | |
tree | 522c5ee89e4af0948b8e645237678f46ec8d3d5c /packages/sol-tracing-utils/test/utils_test.ts | |
parent | 686f27a96f0cd749f6315d7edd2bb56cf1819245 (diff) | |
parent | b8e3829fdbd1f516686618562172cb45fbb63bde (diff) | |
download | dexon-0x-contracts-6c22594882c94146519ec6e3b24d558127bd092c.tar dexon-0x-contracts-6c22594882c94146519ec6e3b24d558127bd092c.tar.gz dexon-0x-contracts-6c22594882c94146519ec6e3b24d558127bd092c.tar.bz2 dexon-0x-contracts-6c22594882c94146519ec6e3b24d558127bd092c.tar.lz dexon-0x-contracts-6c22594882c94146519ec6e3b24d558127bd092c.tar.xz dexon-0x-contracts-6c22594882c94146519ec6e3b24d558127bd092c.tar.zst dexon-0x-contracts-6c22594882c94146519ec6e3b24d558127bd092c.zip |
Merge pull request #1492 from 0xProject/feature/sol-cov-sol-profiler-sol-trace-divorce
Refactor out sol-cov, sol-profiler and sol-trace into their separate packages
Diffstat (limited to 'packages/sol-tracing-utils/test/utils_test.ts')
-rw-r--r-- | packages/sol-tracing-utils/test/utils_test.ts | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/packages/sol-tracing-utils/test/utils_test.ts b/packages/sol-tracing-utils/test/utils_test.ts new file mode 100644 index 000000000..6fc8fcfe1 --- /dev/null +++ b/packages/sol-tracing-utils/test/utils_test.ts @@ -0,0 +1,53 @@ +import * as chai from 'chai'; +import * as dirtyChai from 'dirty-chai'; +import 'mocha'; + +import { utils } from '../src/utils'; + +chai.use(dirtyChai); +const expect = chai.expect; + +describe('utils', () => { + describe('#compareLineColumn', () => { + it('correctly compares LineColumns', () => { + expect(utils.compareLineColumn({ line: 1, column: 3 }, { line: 1, column: 4 })).to.be.lessThan(0); + expect(utils.compareLineColumn({ line: 1, column: 4 }, { line: 1, column: 3 })).to.be.greaterThan(0); + expect(utils.compareLineColumn({ line: 1, column: 3 }, { line: 1, column: 3 })).to.be.equal(0); + expect(utils.compareLineColumn({ line: 0, column: 2 }, { line: 1, column: 0 })).to.be.lessThan(0); + expect(utils.compareLineColumn({ line: 1, column: 0 }, { line: 0, column: 2 })).to.be.greaterThan(0); + }); + }); + + describe('#isRangeInside', () => { + it('returns true if inside', () => { + expect( + utils.isRangeInside( + { start: { line: 1, column: 3 }, end: { line: 1, column: 4 } }, + { start: { line: 1, column: 2 }, end: { line: 1, column: 5 } }, + ), + ).to.be.true(); + }); + it('returns true if the same', () => { + expect( + utils.isRangeInside( + { start: { line: 1, column: 3 }, end: { line: 1, column: 4 } }, + { start: { line: 1, column: 3 }, end: { line: 1, column: 4 } }, + ), + ).to.be.true(); + }); + it('returns false if not inside', () => { + expect( + utils.isRangeInside( + { start: { line: 1, column: 3 }, end: { line: 1, column: 4 } }, + { start: { line: 1, column: 4 }, end: { line: 1, column: 4 } }, + ), + ).to.be.false(); + expect( + utils.isRangeInside( + { start: { line: 1, column: 3 }, end: { line: 1, column: 4 } }, + { start: { line: 1, column: 4 }, end: { line: 1, column: 5 } }, + ), + ).to.be.false(); + }); + }); +}); |