Permalink
Browse files

setup for unit tests

  • Loading branch information...
1 parent dc56c27 commit e195ccce84b7beb5cb26613675adc4623156c455 @niklauslee niklauslee committed Jun 23, 2014
View
@@ -8,5 +8,5 @@ Thumbs.db
.DS_Store
#Java Test Sources
-/test/src-jdk
+/unittest-files/src-jdk
jisonOutput.txt
View
@@ -109,7 +109,7 @@ packageDeclaration
{
$$ = {
"node": "Package",
- "name": $2
+ "qualifiedName": $2
};
}
;
@@ -1263,7 +1263,7 @@ lastFormalParameter
"type": $2,
"variable": $4,
"modifiers": $1
- };
+ };
}
| type ELLIPSIS variableDeclaratorId
{
@@ -1435,7 +1435,7 @@ annotationTypeDeclaration
"extends": $5,
"body": $6
};
- }
+ }
;
annotationTypeBody
@@ -1557,9 +1557,9 @@ defaultValue
block
: LBRACE RBRACE
-
+
| LBRACE blockStatementList RBRACE
-
+
;
blockStatements
@@ -1576,9 +1576,9 @@ blockStatement
: statement
/*| typeDeclaration */
| LBRACE RBRACE
-
+
| LBRACE blockStatementList RBRACE
-
+
;
localVariableDeclarationStatement
@@ -1633,7 +1633,7 @@ variableDeclaratorsWithPrefixes
| modifierL annotationl localVariableDeclaration
| modifierL localVariableDeclaration
| annotationl localVariableDeclaration
- | localVariableDeclaration
+ | localVariableDeclaration
;
simpleExpressionStatement
@@ -1720,7 +1720,7 @@ switchLabel
forControl
: enhancedForControl
-
+
| forInit SEMI optionalExpression SEMI optionalForUpdate
| SEMI optionalExpression SEMI optionalForUpdate
;
@@ -1864,7 +1864,7 @@ expression
| expression DOT SUPER DOT expression
| expression DOT SUPER arguments
| expression DOT SUPER LPAREN RPAREN
- | expression
+ | expression
| qualifiedName DOT newCreator
| expression DOT newCreator /* openjdk/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java:487 */
| qualifiedName arrayDimensionBrackl DOT CLASS
@@ -1875,7 +1875,7 @@ expression
| expression DOT THIS
| expression DOT NEW optionalNonWildcardTypeArguments innerCreator
| qualifiedName DOT explicitGenericInvocation
- | expression DOT qualifiedName
+ | expression DOT qualifiedName
| expression DOT typeParameters Identifier arguments
| expression LBRACK expression RBRACK
| qualifiedName LBRACK expression RBRACK
View
@@ -143,7 +143,7 @@ break;
case 10:
this.$ = {
"node": "Package",
- "name": $$[$0-1]
+ "qualifiedName": $$[$0-1]
};
break;
@@ -1023,7 +1023,7 @@ case 216:
"type": $$[$0-2],
"variable": $$[$0],
"modifiers": $$[$0-3]
- };
+ };
break;
case 217:
File renamed without changes.
File renamed without changes.
View
@@ -23,22 +23,99 @@
/*jslint vars: true, plusplus: true, devel: true, browser: true, nomen: true, indent: 4, maxerr: 50 */
-/*global define, describe, it, xit, expect, beforeEach, afterEach, waitsFor, runs, $, staruml, waitsForDone */
+/*global define, describe, it, xit, expect, beforeEach, afterEach, waitsFor, runs, $, staruml, waitsForDone, java7 */
define(function (require, exports, module) {
"use strict";
// Modules from the SpecRunner window
- var SpecRunnerUtils = staruml.getModule("spec/SpecRunnerUtils");
+ var SpecRunnerUtils = staruml.getModule("spec/SpecRunnerUtils"),
+ FileUtils = staruml.getModule("file/FileUtils"),
+ FileSystem = staruml.getModule("filesystem/FileSystem"),
+ ExtensionUtils = staruml.getModule("utils/ExtensionUtils");
- describe("Java Support", function () {
+ require("grammar/java7");
- it("test", function () {
+ describe("Java Parser", function () {
+
+ it("can parse CompilationUnit", function () {
+ var parseComplete,
+ ast;
+
+ runs(function () {
+ var path = ExtensionUtils.getModulePath(module) + "unittest-files/ClassTest.java";
+ var file = FileSystem.getFileForPath(path);
+ file.read({}, function (err, data, stat) {
+ if (!err) {
+ ast = java7.parse(data);
+ parseComplete = true;
+ console.log(ast);
+ }
+ });
+ });
+
+ waitsFor(
+ function () { return parseComplete; },
+ "Waiting for parsing",
+ 3000
+ );
+
+ runs(function () {
+ expect(ast.node).toEqual("CompilationUnit");
+ expect(ast["package"].node).toEqual("Package");
+ expect(ast["package"].qualifiedName.node).toEqual("QualifiedName");
+ expect(ast["package"].qualifiedName.name).toEqual("com.mycompany.test");
+
+ // TODO: Test import statements.
+
+ });
+ });
+
+ it("can parse Class", function () {
+ var parseComplete,
+ ast;
+
+ runs(function () {
+ var path = ExtensionUtils.getModulePath(module) + "unittest-files/ClassTest.java";
+ var file = FileSystem.getFileForPath(path);
+ file.read({}, function (err, data, stat) {
+ if (!err) {
+ ast = java7.parse(data);
+ parseComplete = true;
+ }
+ });
+ });
+
+ waitsFor(
+ function () { return parseComplete; },
+ "Waiting for parsing",
+ 3000
+ );
+
+ runs(function () {
+
+ });
});
- it("test2", function () {
+ it("can parse Fields", function () {
+
+ });
+
+ it("can parse Operations", function () {
+
+ });
+
+ it("can parse Interface", function () {
+
+ });
+
+ it("can parse Enum", function () {
+
});
+ it("can parse AnnotationType", function () {
+
+ });
});
});

0 comments on commit e195ccc

Please sign in to comment.