-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement simple test harness running printer via remoting (#117)
* Implement simple test harness running printer via remoting * Disable variable declarations test for now * Add ability to disable print idempotence check * Remove rewrite-remote dependency from package.json * Send `reset` command before printing Also add semicolon handling. * Added separate `expressionStatement.test.ts`
- Loading branch information
1 parent
0351b0e
commit 5ced39c
Showing
9 changed files
with
336 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
export {} | ||
import {LstType, Marker, MarkerSymbol, UUID} from "../core"; | ||
|
||
@LstType("org.openrewrite.java.marker.Semicolon") | ||
export class Semicolon implements Marker { | ||
[MarkerSymbol] = true; | ||
private readonly _id: UUID; | ||
|
||
constructor(id: UUID) { | ||
this._id = id; | ||
} | ||
|
||
get id() { | ||
return this._id; | ||
} | ||
|
||
withId(id: UUID): Semicolon { | ||
return id == this._id ? this : new Semicolon(id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
openrewrite/test/javascript/parser/expressionStatement.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {javaScript, rewriteRunWithOptions} from './testHarness'; | ||
|
||
describe('variable declaration mapping', () => { | ||
test('literal with semicolon', () => { | ||
rewriteRunWithOptions( | ||
{normalizeIndent: false}, | ||
javaScript('1 ;') | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as J from "../../../dist/java/tree"; | ||
import * as JS from "../../../dist/javascript/tree"; | ||
import {javaScript, rewriteRunWithOptions} from './testHarness'; | ||
|
||
describe('literal mapping', () => { | ||
test('number', () => { | ||
rewriteRunWithOptions( | ||
{normalizeIndent: false}, | ||
javaScript('1', sourceFile => { | ||
expect(sourceFile).toBeDefined(); | ||
expect(sourceFile.statements).toHaveLength(1); | ||
let statement = sourceFile.statements[0]; | ||
expect(statement).toBeInstanceOf(JS.ExpressionStatement); | ||
let expression = (statement as JS.ExpressionStatement).expression; | ||
expect(expression).toBeInstanceOf(J.Literal); | ||
expect((expression as J.Literal).valueSource).toBe('1'); | ||
})); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {InMemoryExecutionContext, ParserInput} from '../../../dist/core'; | ||
import {JavaScriptParser} from "../../../dist/javascript"; | ||
import * as JS from "../../../dist/javascript/tree"; | ||
|
||
describe('Parser API', () => { | ||
const parser = JavaScriptParser.builder().build(); | ||
|
||
test('parseInputs', () => { | ||
const [sourceFile] = parser.parseInputs( | ||
[new ParserInput('foo.ts', null, true, () => Buffer.from('1', 'utf8'))], | ||
null, | ||
new InMemoryExecutionContext() | ||
) as Iterable<JS.CompilationUnit>; | ||
expect(sourceFile).toBeDefined(); | ||
}); | ||
|
||
test('parseStrings', () => { | ||
const [sourceFile] = parser.parseStrings(` | ||
const c = 1; | ||
/* c1*/ /*c2 */const d = 1;`) as Iterable<JS.CompilationUnit>; | ||
expect(sourceFile).toBeDefined(); | ||
}); | ||
}); |
Oops, something went wrong.