Skip to content

Commit

Permalink
put tests into the right package
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasgal committed Jul 15, 2014
1 parent 1041f93 commit b339dc6
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ SRC = zipfile.js \
jvm.js \
main.js

TESTS_SRC = $(shell ls tests/*.java)
TESTS_BIN = $(TESTS_SRC:.java=.class)

tests: $(TESTS_BIN)

%.class: %.java
javac -classpath java/cldc1.1.1.jar $<

j2me.js: $(SRC)
cat $^ > $@

Expand Down
2 changes: 1 addition & 1 deletion classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Classes.prototype.loadClassFile = function(fileName) {
var classes = classInfo.classes;
for (var i=0; i<classes.length; i++) {
if (!this.classes[classes[i]]) {
this.loadClassFile(path.dirname(fileName) + path.sep + classes[i] + ".class");
this.loadClassFile(fileName.replace(/[^/]*\.class$/, "") + "/" + classes[i] + ".class");
}
}
return classInfo;
Expand Down
2 changes: 1 addition & 1 deletion classfile/classfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ var getClassImage = function(classBytes) {
break;
case TAGS.CONSTANT_Double:
case TAGS.CONSTANT_Long:
var bytes = new Buffer(8);
var bytes = new Uint8Array(8);
for (var b=0; b<8; b++) {
bytes[b] = reader.read8();
}
Expand Down
2 changes: 1 addition & 1 deletion classinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var ClassInfo = function(classBytes) {
self.methods.push(method);
});

this.classes = [];
var classes = this.classes = [];
classImage.attributes.forEach(function(a) {
if (a.info.type === ATTRIBUTE_TYPES.InnerClasses) {
a.info.classes.forEach(function(c) {
Expand Down
6 changes: 3 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ function load(file, cb) {
xhr.send(null);
}

function runTest(path, name, cb) {
function runTest(name, cb) {
var jvm = new JVM();
load("java/cldc1.1.1.jar", function (data) {
jvm.addPath("java/cldc1.1.1.jar", data);
load(path + name, function (data) {
load(name, function (data) {
jvm.addPath(name, data);
jvm.loadClassFile(name);
jvm.start();
Expand All @@ -26,4 +26,4 @@ function runTest(path, name, cb) {
});
}

runTest("tests/", "TestPrintln.class");
runTest("tests/TestPrintln.class")
Binary file modified tests/TestPrintln.class
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/TestPrintln.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package tests;

public class TestPrintln {
public static void main(String[] args) {
System.out.println("OK");
Expand Down

0 comments on commit b339dc6

Please sign in to comment.