Commit d8f78e07488e4386aa5157cda55f653615089f20

Authored by Sergey Reymerov
1 parent 142aa9a5

Mocha testing for nodejs

Showing 3 changed files with 40 additions and 15 deletions   Show diff stats
.gitignore
... ... @@ -2,7 +2,7 @@
2 2  
3 3 *.sublime-project
4 4 *.sublime-workspace
5   -tests/doppio
  5 +test/doppio
6 6  
7 7 ### OSX ###
8 8 .DS_Store
... ... @@ -89,4 +89,4 @@ $RECYCLE.BIN/
89 89 .directory
90 90  
91 91 # Linux trash folder which might appear on any partition or disk
92   -.Trash-*
93 92 \ No newline at end of file
  93 +.Trash-*
... ...
README.md
... ... @@ -3,17 +3,17 @@
3 3 ## Building
4 4  
5 5 There is a Grunt script for building JavaPoly. So for building you have to install `grunt-cli`. Just type command:
6   -```bash
  6 +```sh
7 7 $ npm install -g grunt-cli
8 8 ```
9 9  
10 10 After this install all needed packages and type:
11   -```bash
  11 +```sh
12 12 $ npm install
13 13 ```
14 14  
15 15 For building JavaPoly run command:
16   -```bash
  16 +```sh
17 17 $ grunt build
18 18 ```
19 19  
... ... @@ -22,7 +22,7 @@ This creates `build/javapoly.js` file.
22 22 ### Development JavaPoly
23 23  
24 24 To develop JavaPoly you have to run command:
25   -```bash
  25 +```sh
26 26 $ grunt watch
27 27 ```
28 28  
... ... @@ -30,27 +30,34 @@ This command runs watching process that updates build-file when you change any j
30 30  
31 31 ### Testing JavaPoly
32 32  
33   -There is a folder `tests` which should have to contain simple build of Doppio and JavaPoly.
  33 +There is a folder `test` which should have to contain simple build of Doppio and JavaPoly.
34 34  
35   -Make a build of Doppio and put it into folder `tests/doppio`.
  35 +Make a build of Doppio and put it into folder `test/doppio`.
36 36  
37   -Have in view that **watch**ing-process updates JavaPoly build in `tests` folder.
  37 +Have in view that **watch**ing-process updates JavaPoly build in `test` folder.
38 38  
39 39 But you can rebuild JavaPoly for testing without watching by command:
40   -```bash
  40 +```sh
41 41 $ grunt build:test
42 42 ```
43 43  
44   -To test JavaPoly you should run HTTP server for folder `tests` and open `index.html` in browser.
  44 +To test JavaPoly you should run HTTP server for folder `test` and open `index.html` in browser.
45 45  
46 46 Simplest way to do this is using light HTTP server `http-server`. To install this run command:
47   -```bash
  47 +```sh
48 48 $ npm install -g http-server
49 49 ```
50 50  
51   -And then locate to folder `tests` and run there command:
52   -```bash
  51 +And then locate to folder `test` and run there command:
  52 +```sh
53 53 $ http-server
54 54 ```
55 55  
56   -After this open browser and locate into the page http://localhost:8080/index.html
57 56 \ No newline at end of file
  57 +After this open browser and locate into the page http://localhost:8080/index.html. You'll a page index.html that contains Mocha tests environment.
  58 +
  59 +Also you can test JavaPoly via Mocha in nodejs. Install it by typing:
  60 +```sh
  61 +$ npm install -g mocha
  62 +```
  63 +
  64 +And type `mocha` in projects directory.
58 65 \ No newline at end of file
... ...
test/classfile.js 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +var assert = require('assert');
  2 +var classfile = require('./../src/tools/classfile.js');
  3 +var fs = require('fs');
  4 +var path = require('path');
  5 +
  6 +describe('classfile', function() {
  7 + describe('#analyze', function () {
  8 + it('classes/Main.class', function () {
  9 + fs.readFile(path.join(__dirname, './classes/Main.class'), (err, data)=> {
  10 + var info = classfile.analyze(data);
  11 + assert.equal(info.this_class, 'Main');
  12 + assert.equal(info.super_class, 'java/lang/Object');
  13 + })
  14 + });
  15 + });
  16 +});
  17 +
  18 +
... ...