refactor: IS_DART === false
This commit is contained in:
parent
28c4852cd6
commit
106db0aba8
|
@ -9,7 +9,6 @@
|
|||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit,} from '@angular/core/testing/testing_internal';
|
||||
import {TestComponentBuilder} from '@angular/core/testing';
|
||||
import {ListWrapper} from '../../src/facade/collection';
|
||||
import {IS_DART} from '../../src/facade/lang';
|
||||
import {Component, TemplateRef, ContentChild} from '@angular/core';
|
||||
import {NgFor, NgIf} from '@angular/common';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
@ -171,25 +170,21 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
if (!IS_DART) {
|
||||
it('should throw on non-iterable ref and suggest using an array',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideTemplate(TestComponent, TEMPLATE)
|
||||
.createAsync(TestComponent)
|
||||
.then((fixture) => {
|
||||
fixture.debugElement.componentInstance.items = 'whaaa';
|
||||
try {
|
||||
fixture.detectChanges();
|
||||
} catch (e) {
|
||||
expect(e.message).toContain(
|
||||
`Cannot find a differ supporting object 'whaaa' of type 'string'. NgFor only supports binding to Iterables such as Arrays.`);
|
||||
async.done();
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
it('should throw on non-iterable ref and suggest using an array',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideTemplate(TestComponent, TEMPLATE).createAsync(TestComponent).then((fixture) => {
|
||||
fixture.debugElement.componentInstance.items = 'whaaa';
|
||||
try {
|
||||
fixture.detectChanges();
|
||||
} catch (e) {
|
||||
expect(e.message).toContain(
|
||||
`Cannot find a differ supporting object 'whaaa' of type 'string'. NgFor only supports binding to Iterables such as Arrays.`);
|
||||
async.done();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
it('should throw on ref changing to string',
|
||||
inject(
|
||||
|
|
|
@ -14,8 +14,6 @@ import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
|||
import {Component} from '@angular/core';
|
||||
import {NgIf} from '@angular/common';
|
||||
|
||||
import {IS_DART} from '../../src/facade/lang';
|
||||
|
||||
export function main() {
|
||||
describe('ngIf directive', () => {
|
||||
it('should work in a template attribute',
|
||||
|
@ -189,84 +187,58 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should not add the element twice if the condition goes from true to true (JS)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
var html = '<div><copy-me template="ngIf numberCondition">hello</copy-me></div>';
|
||||
|
||||
if (!IS_DART) {
|
||||
it('should not add the element twice if the condition goes from true to true (JS)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
var html = '<div><copy-me template="ngIf numberCondition">hello</copy-me></div>';
|
||||
tcb.overrideTemplate(TestComponent, html)
|
||||
.createAsync(TestComponent)
|
||||
.then((fixture) => {
|
||||
fixture.detectChanges();
|
||||
expect(getDOM()
|
||||
.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me')
|
||||
.length)
|
||||
.toEqual(1);
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('hello');
|
||||
|
||||
tcb.overrideTemplate(TestComponent, html)
|
||||
.createAsync(TestComponent)
|
||||
.then((fixture) => {
|
||||
fixture.detectChanges();
|
||||
expect(getDOM()
|
||||
.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me')
|
||||
.length)
|
||||
.toEqual(1);
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('hello');
|
||||
fixture.debugElement.componentInstance.numberCondition = 2;
|
||||
fixture.detectChanges();
|
||||
expect(getDOM()
|
||||
.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me')
|
||||
.length)
|
||||
.toEqual(1);
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('hello');
|
||||
|
||||
fixture.debugElement.componentInstance.numberCondition = 2;
|
||||
fixture.detectChanges();
|
||||
expect(getDOM()
|
||||
.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me')
|
||||
.length)
|
||||
.toEqual(1);
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('hello');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
it('should not recreate the element if the condition goes from true to true (JS)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
var html = '<div><copy-me template="ngIf numberCondition">hello</copy-me></div>';
|
||||
|
||||
it('should not recreate the element if the condition goes from true to true (JS)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
var html = '<div><copy-me template="ngIf numberCondition">hello</copy-me></div>';
|
||||
tcb.overrideTemplate(TestComponent, html)
|
||||
.createAsync(TestComponent)
|
||||
.then((fixture) => {
|
||||
fixture.detectChanges();
|
||||
getDOM().addClass(
|
||||
getDOM().querySelector(fixture.debugElement.nativeElement, 'copy-me'),
|
||||
'foo');
|
||||
|
||||
tcb.overrideTemplate(TestComponent, html)
|
||||
.createAsync(TestComponent)
|
||||
.then((fixture) => {
|
||||
fixture.detectChanges();
|
||||
getDOM().addClass(
|
||||
getDOM().querySelector(fixture.debugElement.nativeElement, 'copy-me'),
|
||||
'foo');
|
||||
|
||||
fixture.debugElement.componentInstance.numberCondition = 2;
|
||||
fixture.detectChanges();
|
||||
expect(
|
||||
getDOM().hasClass(
|
||||
getDOM().querySelector(fixture.debugElement.nativeElement, 'copy-me'),
|
||||
'foo'))
|
||||
.toBe(true);
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
if (IS_DART) {
|
||||
it('should not create the element if the condition is not a boolean (DART)',
|
||||
inject(
|
||||
[TestComponentBuilder, AsyncTestCompleter],
|
||||
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
var html = '<div><copy-me template="ngIf numberCondition">hello</copy-me></div>';
|
||||
|
||||
tcb.overrideTemplate(TestComponent, html)
|
||||
.createAsync(TestComponent)
|
||||
.then((fixture) => {
|
||||
expect(() => fixture.detectChanges()).toThrowError();
|
||||
expect(getDOM()
|
||||
.querySelectorAll(fixture.debugElement.nativeElement, 'copy-me')
|
||||
.length)
|
||||
.toEqual(0);
|
||||
expect(fixture.debugElement.nativeElement).toHaveText('');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
}
|
||||
fixture.debugElement.componentInstance.numberCondition = 2;
|
||||
fixture.detectChanges();
|
||||
expect(getDOM().hasClass(
|
||||
getDOM().querySelector(fixture.debugElement.nativeElement, 'copy-me'),
|
||||
'foo'))
|
||||
.toBe(true);
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach, inject,} from '@angular/core/testing/testing_internal';
|
||||
import {fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {ControlGroup, Control, ControlArray, Validators} from '@angular/common/src/forms-deprecated';
|
||||
import {IS_DART, isPresent} from '../../src/facade/lang';
|
||||
import {isPresent} from '../../src/facade/lang';
|
||||
import {PromiseWrapper} from '../../src/facade/promise';
|
||||
import {TimerWrapper, ObservableWrapper, EventEmitter} from '../../src/facade/async';
|
||||
|
||||
|
@ -251,17 +251,15 @@ export function main() {
|
|||
}));
|
||||
|
||||
// TODO: remove the if statement after making observable delivery sync
|
||||
if (!IS_DART) {
|
||||
it('should update set errors and status before emitting an event',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
c.valueChanges.subscribe((value: any /** TODO #9100 */) => {
|
||||
expect(c.valid).toEqual(false);
|
||||
expect(c.errors).toEqual({'required': true});
|
||||
async.done();
|
||||
});
|
||||
c.updateValue('');
|
||||
}));
|
||||
}
|
||||
it('should update set errors and status before emitting an event',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
c.valueChanges.subscribe((value: any /** TODO #9100 */) => {
|
||||
expect(c.valid).toEqual(false);
|
||||
expect(c.errors).toEqual({'required': true});
|
||||
async.done();
|
||||
});
|
||||
c.updateValue('');
|
||||
}));
|
||||
|
||||
it('should return a cold observable',
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
|
|
|
@ -1,379 +0,0 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {CompileIdentifierMetadata} from '../compile_metadata';
|
||||
import {BaseException} from '../facade/exceptions';
|
||||
import {isArray, isBlank, isPresent} from '../facade/lang';
|
||||
|
||||
import * as o from './output_ast';
|
||||
|
||||
import {OutputEmitter, EmitterVisitorContext, AbstractEmitterVisitor, CATCH_ERROR_VAR, CATCH_STACK_VAR,} from './abstract_emitter';
|
||||
import {ImportGenerator} from './path_util';
|
||||
|
||||
var _debugModuleUrl = 'asset://debug/lib';
|
||||
|
||||
export function debugOutputAstAsDart(ast: o.Statement | o.Expression | o.Type | any[]): string {
|
||||
var converter = new _DartEmitterVisitor(_debugModuleUrl);
|
||||
var ctx = EmitterVisitorContext.createRoot([]);
|
||||
var asts: any[];
|
||||
if (isArray(ast)) {
|
||||
asts = <any[]>ast;
|
||||
} else {
|
||||
asts = [ast];
|
||||
}
|
||||
asts.forEach((ast) => {
|
||||
if (ast instanceof o.Statement) {
|
||||
ast.visitStatement(converter, ctx);
|
||||
} else if (ast instanceof o.Expression) {
|
||||
ast.visitExpression(converter, ctx);
|
||||
} else if (ast instanceof o.Type) {
|
||||
ast.visitType(converter, ctx);
|
||||
} else {
|
||||
throw new BaseException(`Don't know how to print debug info for ${ast}`);
|
||||
}
|
||||
});
|
||||
return ctx.toSource();
|
||||
}
|
||||
|
||||
export class DartEmitter implements OutputEmitter {
|
||||
constructor(private _importGenerator: ImportGenerator) {}
|
||||
emitStatements(moduleUrl: string, stmts: o.Statement[], exportedVars: string[]): string {
|
||||
var srcParts: any[] /** TODO #9100 */ = [];
|
||||
// Note: We are not creating a library here as Dart does not need it.
|
||||
// Dart analzyer might complain about it though.
|
||||
|
||||
var converter = new _DartEmitterVisitor(moduleUrl);
|
||||
var ctx = EmitterVisitorContext.createRoot(exportedVars);
|
||||
converter.visitAllStatements(stmts, ctx);
|
||||
|
||||
converter.importsWithPrefixes.forEach((prefix, importedModuleUrl) => {
|
||||
srcParts.push(
|
||||
`import '${this._importGenerator.getImportPath(moduleUrl, importedModuleUrl)}' as ${prefix};`);
|
||||
});
|
||||
srcParts.push(ctx.toSource());
|
||||
return srcParts.join('\n');
|
||||
}
|
||||
}
|
||||
|
||||
class _DartEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor {
|
||||
importsWithPrefixes = new Map<string, string>();
|
||||
|
||||
constructor(private _moduleUrl: string) { super(true); }
|
||||
|
||||
visitExternalExpr(ast: o.ExternalExpr, ctx: EmitterVisitorContext): any {
|
||||
this._visitIdentifier(ast.value, ast.typeParams, ctx);
|
||||
return null;
|
||||
}
|
||||
visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: EmitterVisitorContext): any {
|
||||
if (stmt.hasModifier(o.StmtModifier.Final)) {
|
||||
if (isConstType(stmt.type)) {
|
||||
ctx.print(`const `);
|
||||
} else {
|
||||
ctx.print(`final `);
|
||||
}
|
||||
} else if (isBlank(stmt.type)) {
|
||||
ctx.print(`var `);
|
||||
}
|
||||
if (isPresent(stmt.type)) {
|
||||
stmt.type.visitType(this, ctx);
|
||||
ctx.print(` `);
|
||||
}
|
||||
ctx.print(`${stmt.name} = `);
|
||||
stmt.value.visitExpression(this, ctx);
|
||||
ctx.println(`;`);
|
||||
return null;
|
||||
}
|
||||
visitCastExpr(ast: o.CastExpr, ctx: EmitterVisitorContext): any {
|
||||
ctx.print(`(`);
|
||||
ast.value.visitExpression(this, ctx);
|
||||
ctx.print(` as `);
|
||||
ast.type.visitType(this, ctx);
|
||||
ctx.print(`)`);
|
||||
return null;
|
||||
}
|
||||
visitDeclareClassStmt(stmt: o.ClassStmt, ctx: EmitterVisitorContext): any {
|
||||
ctx.pushClass(stmt);
|
||||
ctx.print(`class ${stmt.name}`);
|
||||
if (isPresent(stmt.parent)) {
|
||||
ctx.print(` extends `);
|
||||
stmt.parent.visitExpression(this, ctx);
|
||||
}
|
||||
ctx.println(` {`);
|
||||
ctx.incIndent();
|
||||
stmt.fields.forEach((field) => this._visitClassField(field, ctx));
|
||||
if (isPresent(stmt.constructorMethod)) {
|
||||
this._visitClassConstructor(stmt, ctx);
|
||||
}
|
||||
stmt.getters.forEach((getter) => this._visitClassGetter(getter, ctx));
|
||||
stmt.methods.forEach((method) => this._visitClassMethod(method, ctx));
|
||||
ctx.decIndent();
|
||||
ctx.println(`}`);
|
||||
ctx.popClass();
|
||||
return null;
|
||||
}
|
||||
private _visitClassField(field: o.ClassField, ctx: EmitterVisitorContext) {
|
||||
if (field.hasModifier(o.StmtModifier.Final)) {
|
||||
ctx.print(`final `);
|
||||
} else if (isBlank(field.type)) {
|
||||
ctx.print(`var `);
|
||||
}
|
||||
if (isPresent(field.type)) {
|
||||
field.type.visitType(this, ctx);
|
||||
ctx.print(` `);
|
||||
}
|
||||
ctx.println(`${field.name};`);
|
||||
}
|
||||
private _visitClassGetter(getter: o.ClassGetter, ctx: EmitterVisitorContext) {
|
||||
if (isPresent(getter.type)) {
|
||||
getter.type.visitType(this, ctx);
|
||||
ctx.print(` `);
|
||||
}
|
||||
ctx.println(`get ${getter.name} {`);
|
||||
ctx.incIndent();
|
||||
this.visitAllStatements(getter.body, ctx);
|
||||
ctx.decIndent();
|
||||
ctx.println(`}`);
|
||||
}
|
||||
private _visitClassConstructor(stmt: o.ClassStmt, ctx: EmitterVisitorContext) {
|
||||
ctx.print(`${stmt.name}(`);
|
||||
this._visitParams(stmt.constructorMethod.params, ctx);
|
||||
ctx.print(`)`);
|
||||
|
||||
var ctorStmts = stmt.constructorMethod.body;
|
||||
var superCtorExpr = ctorStmts.length > 0 ? getSuperConstructorCallExpr(ctorStmts[0]) : null;
|
||||
if (isPresent(superCtorExpr)) {
|
||||
ctx.print(`: `);
|
||||
superCtorExpr.visitExpression(this, ctx);
|
||||
ctorStmts = ctorStmts.slice(1);
|
||||
}
|
||||
ctx.println(` {`);
|
||||
ctx.incIndent();
|
||||
this.visitAllStatements(ctorStmts, ctx);
|
||||
ctx.decIndent();
|
||||
ctx.println(`}`);
|
||||
}
|
||||
private _visitClassMethod(method: o.ClassMethod, ctx: EmitterVisitorContext) {
|
||||
if (isPresent(method.type)) {
|
||||
method.type.visitType(this, ctx);
|
||||
} else {
|
||||
ctx.print(`void`);
|
||||
}
|
||||
ctx.print(` ${method.name}(`);
|
||||
this._visitParams(method.params, ctx);
|
||||
ctx.println(`) {`);
|
||||
ctx.incIndent();
|
||||
this.visitAllStatements(method.body, ctx);
|
||||
ctx.decIndent();
|
||||
ctx.println(`}`);
|
||||
}
|
||||
|
||||
visitFunctionExpr(ast: o.FunctionExpr, ctx: EmitterVisitorContext): any {
|
||||
ctx.print(`(`);
|
||||
this._visitParams(ast.params, ctx);
|
||||
ctx.println(`) {`);
|
||||
ctx.incIndent();
|
||||
this.visitAllStatements(ast.statements, ctx);
|
||||
ctx.decIndent();
|
||||
ctx.print(`}`);
|
||||
return null;
|
||||
}
|
||||
visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, ctx: EmitterVisitorContext): any {
|
||||
if (isPresent(stmt.type)) {
|
||||
stmt.type.visitType(this, ctx);
|
||||
} else {
|
||||
ctx.print(`void`);
|
||||
}
|
||||
ctx.print(` ${stmt.name}(`);
|
||||
this._visitParams(stmt.params, ctx);
|
||||
ctx.println(`) {`);
|
||||
ctx.incIndent();
|
||||
this.visitAllStatements(stmt.statements, ctx);
|
||||
ctx.decIndent();
|
||||
ctx.println(`}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
getBuiltinMethodName(method: o.BuiltinMethod): string {
|
||||
var name: any /** TODO #9100 */;
|
||||
switch (method) {
|
||||
case o.BuiltinMethod.ConcatArray:
|
||||
name = '.addAll';
|
||||
break;
|
||||
case o.BuiltinMethod.SubscribeObservable:
|
||||
name = 'listen';
|
||||
break;
|
||||
case o.BuiltinMethod.bind:
|
||||
name = null;
|
||||
break;
|
||||
default:
|
||||
throw new BaseException(`Unknown builtin method: ${method}`);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
visitTryCatchStmt(stmt: o.TryCatchStmt, ctx: EmitterVisitorContext): any {
|
||||
ctx.println(`try {`);
|
||||
ctx.incIndent();
|
||||
this.visitAllStatements(stmt.bodyStmts, ctx);
|
||||
ctx.decIndent();
|
||||
ctx.println(`} catch (${CATCH_ERROR_VAR.name}, ${CATCH_STACK_VAR.name}) {`);
|
||||
ctx.incIndent();
|
||||
this.visitAllStatements(stmt.catchStmts, ctx);
|
||||
ctx.decIndent();
|
||||
ctx.println(`}`);
|
||||
return null;
|
||||
}
|
||||
visitBinaryOperatorExpr(ast: o.BinaryOperatorExpr, ctx: EmitterVisitorContext): any {
|
||||
switch (ast.operator) {
|
||||
case o.BinaryOperator.Identical:
|
||||
ctx.print(`identical(`);
|
||||
ast.lhs.visitExpression(this, ctx);
|
||||
ctx.print(`, `);
|
||||
ast.rhs.visitExpression(this, ctx);
|
||||
ctx.print(`)`);
|
||||
break;
|
||||
case o.BinaryOperator.NotIdentical:
|
||||
ctx.print(`!identical(`);
|
||||
ast.lhs.visitExpression(this, ctx);
|
||||
ctx.print(`, `);
|
||||
ast.rhs.visitExpression(this, ctx);
|
||||
ctx.print(`)`);
|
||||
break;
|
||||
default:
|
||||
super.visitBinaryOperatorExpr(ast, ctx);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
visitLiteralArrayExpr(ast: o.LiteralArrayExpr, ctx: EmitterVisitorContext): any {
|
||||
if (isConstType(ast.type)) {
|
||||
ctx.print(`const `);
|
||||
}
|
||||
return super.visitLiteralArrayExpr(ast, ctx);
|
||||
}
|
||||
visitLiteralMapExpr(ast: o.LiteralMapExpr, ctx: EmitterVisitorContext): any {
|
||||
if (isConstType(ast.type)) {
|
||||
ctx.print(`const `);
|
||||
}
|
||||
if (isPresent(ast.valueType)) {
|
||||
ctx.print(`<String, `);
|
||||
ast.valueType.visitType(this, ctx);
|
||||
ctx.print(`>`);
|
||||
}
|
||||
return super.visitLiteralMapExpr(ast, ctx);
|
||||
}
|
||||
visitInstantiateExpr(ast: o.InstantiateExpr, ctx: EmitterVisitorContext): any {
|
||||
ctx.print(isConstType(ast.type) ? `const` : `new`);
|
||||
ctx.print(' ');
|
||||
ast.classExpr.visitExpression(this, ctx);
|
||||
ctx.print(`(`);
|
||||
this.visitAllExpressions(ast.args, ctx, `,`);
|
||||
ctx.print(`)`);
|
||||
return null;
|
||||
}
|
||||
visitBuiltintType(type: o.BuiltinType, ctx: EmitterVisitorContext): any {
|
||||
var typeStr: any /** TODO #9100 */;
|
||||
switch (type.name) {
|
||||
case o.BuiltinTypeName.Bool:
|
||||
typeStr = 'bool';
|
||||
break;
|
||||
case o.BuiltinTypeName.Dynamic:
|
||||
typeStr = 'dynamic';
|
||||
break;
|
||||
case o.BuiltinTypeName.Function:
|
||||
typeStr = 'Function';
|
||||
break;
|
||||
case o.BuiltinTypeName.Number:
|
||||
typeStr = 'num';
|
||||
break;
|
||||
case o.BuiltinTypeName.Int:
|
||||
typeStr = 'int';
|
||||
break;
|
||||
case o.BuiltinTypeName.String:
|
||||
typeStr = 'String';
|
||||
break;
|
||||
default:
|
||||
throw new BaseException(`Unsupported builtin type ${type.name}`);
|
||||
}
|
||||
ctx.print(typeStr);
|
||||
return null;
|
||||
}
|
||||
visitExternalType(ast: o.ExternalType, ctx: EmitterVisitorContext): any {
|
||||
this._visitIdentifier(ast.value, ast.typeParams, ctx);
|
||||
return null;
|
||||
}
|
||||
visitArrayType(type: o.ArrayType, ctx: EmitterVisitorContext): any {
|
||||
ctx.print(`List<`);
|
||||
if (isPresent(type.of)) {
|
||||
type.of.visitType(this, ctx);
|
||||
} else {
|
||||
ctx.print(`dynamic`);
|
||||
}
|
||||
ctx.print(`>`);
|
||||
return null;
|
||||
}
|
||||
visitMapType(type: o.MapType, ctx: EmitterVisitorContext): any {
|
||||
ctx.print(`Map<String, `);
|
||||
if (isPresent(type.valueType)) {
|
||||
type.valueType.visitType(this, ctx);
|
||||
} else {
|
||||
ctx.print(`dynamic`);
|
||||
}
|
||||
ctx.print(`>`);
|
||||
return null;
|
||||
}
|
||||
|
||||
private _visitParams(params: o.FnParam[], ctx: EmitterVisitorContext): void {
|
||||
this.visitAllObjects((param: any /** TODO #9100 */) => {
|
||||
if (isPresent(param.type)) {
|
||||
param.type.visitType(this, ctx);
|
||||
ctx.print(' ');
|
||||
}
|
||||
ctx.print(param.name);
|
||||
}, params, ctx, ',');
|
||||
}
|
||||
|
||||
private _visitIdentifier(
|
||||
value: CompileIdentifierMetadata, typeParams: o.Type[], ctx: EmitterVisitorContext): void {
|
||||
if (isBlank(value.name)) {
|
||||
throw new BaseException(`Internal error: unknown identifier ${value}`);
|
||||
}
|
||||
if (isPresent(value.moduleUrl) && value.moduleUrl != this._moduleUrl) {
|
||||
var prefix = this.importsWithPrefixes.get(value.moduleUrl);
|
||||
if (isBlank(prefix)) {
|
||||
prefix = `import${this.importsWithPrefixes.size}`;
|
||||
this.importsWithPrefixes.set(value.moduleUrl, prefix);
|
||||
}
|
||||
ctx.print(`${prefix}.`);
|
||||
}
|
||||
ctx.print(value.name);
|
||||
if (isPresent(typeParams) && typeParams.length > 0) {
|
||||
ctx.print(`<`);
|
||||
this.visitAllObjects(
|
||||
(type: any /** TODO #9100 */) => type.visitType(this, ctx), typeParams, ctx, ',');
|
||||
ctx.print(`>`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getSuperConstructorCallExpr(stmt: o.Statement): o.Expression {
|
||||
if (stmt instanceof o.ExpressionStatement) {
|
||||
var expr = stmt.expr;
|
||||
if (expr instanceof o.InvokeFunctionExpr) {
|
||||
var fn = expr.fn;
|
||||
if (fn instanceof o.ReadVarExpr) {
|
||||
if (fn.builtin === o.BuiltinVar.Super) {
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function isConstType(type: o.Type): boolean {
|
||||
return isPresent(type) && type.hasModifier(o.TypeModifier.Const);
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injectable} from '@angular/core';
|
||||
|
||||
import {BaseException} from '../facade/exceptions';
|
||||
import {Math, RegExpWrapper, isBlank, isPresent} from '../facade/lang';
|
||||
|
||||
import {AssetUrl, ImportGenerator} from './path_util';
|
||||
|
||||
var _PATH_SEP = '/';
|
||||
var _PATH_SEP_RE = /\//g;
|
||||
|
||||
@Injectable()
|
||||
export class DartImportGenerator implements ImportGenerator {
|
||||
getImportPath(moduleUrlStr: string, importedUrlStr: string): string {
|
||||
var moduleUrl = AssetUrl.parse(moduleUrlStr, false);
|
||||
var importedUrl = AssetUrl.parse(importedUrlStr, true);
|
||||
if (isBlank(importedUrl)) {
|
||||
return importedUrlStr;
|
||||
}
|
||||
// Try to create a relative path first
|
||||
if (moduleUrl.firstLevelDir == importedUrl.firstLevelDir &&
|
||||
moduleUrl.packageName == importedUrl.packageName) {
|
||||
return getRelativePath(moduleUrl.modulePath, importedUrl.modulePath);
|
||||
} else if (importedUrl.firstLevelDir == 'lib') {
|
||||
return `package:${importedUrl.packageName}/${importedUrl.modulePath}`;
|
||||
}
|
||||
throw new BaseException(`Can't import url ${importedUrlStr} from ${moduleUrlStr}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function getRelativePath(modulePath: string, importedPath: string): string {
|
||||
var moduleParts = modulePath.split(_PATH_SEP_RE);
|
||||
var importedParts = importedPath.split(_PATH_SEP_RE);
|
||||
var longestPrefix = getLongestPathSegmentPrefix(moduleParts, importedParts);
|
||||
|
||||
var resultParts: any[] /** TODO #9100 */ = [];
|
||||
var goParentCount = moduleParts.length - 1 - longestPrefix;
|
||||
for (var i = 0; i < goParentCount; i++) {
|
||||
resultParts.push('..');
|
||||
}
|
||||
for (var i = longestPrefix; i < importedParts.length; i++) {
|
||||
resultParts.push(importedParts[i]);
|
||||
}
|
||||
return resultParts.join(_PATH_SEP);
|
||||
}
|
||||
|
||||
export function getLongestPathSegmentPrefix(arr1: string[], arr2: string[]): number {
|
||||
var prefixSize = 0;
|
||||
var minLen = Math.min(arr1.length, arr2.length);
|
||||
while (prefixSize < minLen && arr1[prefixSize] == arr2[prefixSize]) {
|
||||
prefixSize++;
|
||||
}
|
||||
return prefixSize;
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
import {ObservableWrapper} from '../facade/async';
|
||||
import {ListWrapper} from '../facade/collection';
|
||||
import {BaseException, unimplemented} from '../facade/exceptions';
|
||||
import {IS_DART, isPresent} from '../facade/lang';
|
||||
import {isPresent} from '../facade/lang';
|
||||
|
||||
import {debugOutputAstAsDart} from './dart_emitter';
|
||||
import * as o from './output_ast';
|
||||
|
@ -89,9 +89,7 @@ function createDynamicClass(
|
|||
}
|
||||
|
||||
class StatementInterpreter implements o.StatementVisitor, o.ExpressionVisitor {
|
||||
debugAst(ast: o.Expression|o.Statement|o.Type): string {
|
||||
return IS_DART ? debugOutputAstAsDart(ast) : debugOutputAstAsTypeScript(ast);
|
||||
}
|
||||
debugAst(ast: o.Expression|o.Statement|o.Type): string { return debugOutputAstAsTypeScript(ast); }
|
||||
|
||||
visitDeclareVarStmt(stmt: o.DeclareVarStmt, ctx: _ExecutionContext): any {
|
||||
ctx.vars.set(stmt.name, stmt.value.visitExpression(this, ctx));
|
||||
|
@ -163,11 +161,7 @@ class StatementInterpreter implements o.StatementVisitor, o.ExpressionVisitor {
|
|||
result = ObservableWrapper.subscribe(receiver, args[0]);
|
||||
break;
|
||||
case o.BuiltinMethod.bind:
|
||||
if (IS_DART) {
|
||||
result = receiver;
|
||||
} else {
|
||||
result = receiver.bind(args[0]);
|
||||
}
|
||||
result = receiver.bind(args[0]);
|
||||
break;
|
||||
default:
|
||||
throw new BaseException(`Unknown builtin method ${expr.builtin}`);
|
||||
|
|
|
@ -15,7 +15,7 @@ import {CompilerConfig} from './config';
|
|||
import {DirectiveNormalizer} from './directive_normalizer';
|
||||
import {PromiseWrapper} from './facade/async';
|
||||
import {BaseException} from './facade/exceptions';
|
||||
import {ConcreteType, IS_DART, Type, isBlank, isString, stringify} from './facade/lang';
|
||||
import {ConcreteType, Type, isBlank, isString, stringify} from './facade/lang';
|
||||
import {CompileMetadataResolver} from './metadata_resolver';
|
||||
import {NgModuleCompiler} from './ng_module_compiler';
|
||||
import * as ir from './output/output_ast';
|
||||
|
@ -145,7 +145,7 @@ export class RuntimeCompiler implements Compiler {
|
|||
this._assertComponentKnown(dep.comp.runtime, true).proxyComponentFactory;
|
||||
dep.placeholder.name = `compFactory_${dep.comp.name}`;
|
||||
});
|
||||
if (IS_DART || !this._compilerConfig.useJit) {
|
||||
if (!this._compilerConfig.useJit) {
|
||||
ngModuleFactory =
|
||||
interpretStatements(compileResult.statements, compileResult.ngModuleFactoryVar);
|
||||
} else {
|
||||
|
@ -312,7 +312,7 @@ export class RuntimeCompiler implements Compiler {
|
|||
const statements =
|
||||
stylesCompileResult.componentStylesheet.statements.concat(compileResult.statements);
|
||||
let factory: any;
|
||||
if (IS_DART || !this._compilerConfig.useJit) {
|
||||
if (!this._compilerConfig.useJit) {
|
||||
factory = interpretStatements(statements, compileResult.viewFactoryVar);
|
||||
} else {
|
||||
factory = jitStatements(
|
||||
|
@ -336,7 +336,7 @@ export class RuntimeCompiler implements Compiler {
|
|||
result: CompiledStylesheet,
|
||||
externalStylesheetsByModuleUrl: Map<string, CompiledStylesheet>): string[] {
|
||||
this._resolveStylesCompileResult(result, externalStylesheetsByModuleUrl);
|
||||
if (IS_DART || !this._compilerConfig.useJit) {
|
||||
if (!this._compilerConfig.useJit) {
|
||||
return interpretStatements(result.statements, result.stylesVar);
|
||||
} else {
|
||||
return jitStatements(`${result.meta.moduleUrl}.css.js`, result.statements, result.stylesVar);
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
import {CompileTokenMetadata} from './compile_metadata';
|
||||
import {StringMapWrapper} from './facade/collection';
|
||||
import {IS_DART, StringWrapper, isArray, isBlank, isPresent, isPrimitive, isStrictStringMap} from './facade/lang';
|
||||
import {StringWrapper, isArray, isBlank, isPresent, isPrimitive, isStrictStringMap} from './facade/lang';
|
||||
import * as o from './output/output_ast';
|
||||
|
||||
export var MODULE_SUFFIX = IS_DART ? '.dart' : '';
|
||||
export const MODULE_SUFFIX = '';
|
||||
|
||||
var CAMEL_CASE_REGEXP = /([A-Z])/g;
|
||||
|
||||
|
@ -65,18 +65,10 @@ export class ValueTransformer implements ValueVisitor {
|
|||
}
|
||||
|
||||
export function assetUrl(pkg: string, path: string = null, type: string = 'src'): string {
|
||||
if (IS_DART) {
|
||||
if (path == null) {
|
||||
return `asset:angular2/${pkg}/${pkg}.dart`;
|
||||
} else {
|
||||
return `asset:angular2/lib/${pkg}/src/${path}.dart`;
|
||||
}
|
||||
if (path == null) {
|
||||
return `asset:@angular/lib/${pkg}/index`;
|
||||
} else {
|
||||
if (path == null) {
|
||||
return `asset:@angular/lib/${pkg}/index`;
|
||||
} else {
|
||||
return `asset:@angular/lib/${pkg}/src/${path}`;
|
||||
}
|
||||
return `asset:@angular/lib/${pkg}/src/${path}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import {TestBed} from '@angular/core/testing';
|
|||
import {afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {CompileNgModuleMetadata} from '../src/compile_metadata';
|
||||
import {IS_DART, stringify} from '../src/facade/lang';
|
||||
import {stringify} from '../src/facade/lang';
|
||||
import {CompileMetadataResolver} from '../src/metadata_resolver';
|
||||
|
||||
import {MalformedStylesComponent} from './metadata_resolver_fixture';
|
||||
|
@ -49,10 +49,9 @@ export function main() {
|
|||
|
||||
it('should use the moduleUrl from the reflector if none is given',
|
||||
inject([CompileMetadataResolver], (resolver: CompileMetadataResolver) => {
|
||||
var value: string =
|
||||
const value: string =
|
||||
resolver.getDirectiveMetadata(ComponentWithoutModuleId).type.moduleUrl;
|
||||
var expectedEndValue =
|
||||
IS_DART ? 'test/compiler/metadata_resolver_spec.dart' : './ComponentWithoutModuleId';
|
||||
const expectedEndValue = './ComponentWithoutModuleId';
|
||||
expect(value.endsWith(expectedEndValue)).toBe(true);
|
||||
}));
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import * as o from '@angular/compiler/src/output/output_ast';
|
|||
import {TypeScriptEmitter} from '@angular/compiler/src/output/ts_emitter';
|
||||
|
||||
import {unimplemented} from '../../src/facade/exceptions';
|
||||
import {IS_DART, print} from '../../src/facade/lang';
|
||||
import {print} from '../../src/facade/lang';
|
||||
import {assetUrl} from '../../src/util';
|
||||
|
||||
import {SimpleJsImportGenerator, codegenExportsVars, codegenStmts} from './output_emitter_util';
|
||||
|
@ -24,16 +24,14 @@ export function getExpressions(): any {
|
|||
|
||||
// Generator
|
||||
export function emit() {
|
||||
var emitter = IS_DART ? new DartEmitter(new DartImportGenerator()) :
|
||||
new TypeScriptEmitter(new SimpleJsImportGenerator());
|
||||
var emittedCode = emitter.emitStatements(
|
||||
const emitter = new TypeScriptEmitter(new SimpleJsImportGenerator());
|
||||
const emittedCode = emitter.emitStatements(
|
||||
assetUrl('compiler', 'output/output_emitter_codegen_typed', 'test'), codegenStmts,
|
||||
codegenExportsVars);
|
||||
return emittedCode;
|
||||
}
|
||||
|
||||
export function main(args: string[]) {
|
||||
var emittedCode = emit();
|
||||
// debug: console.error(emittedCode);
|
||||
const emittedCode = emit();
|
||||
print(emittedCode);
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
import {UrlResolver, createOfflineCompileUrlResolver} from '@angular/compiler/src/url_resolver';
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {IS_DART} from '../src/facade/lang';
|
||||
|
||||
export function main() {
|
||||
describe('UrlResolver', () => {
|
||||
var resolver = new UrlResolver();
|
||||
|
@ -96,18 +94,9 @@ export function main() {
|
|||
expect(resolver.resolve(null, 'some/dir/file.txt')).toEqual('some/dir/file.txt');
|
||||
});
|
||||
|
||||
it('should contain a default value of "/packages" when nothing is provided for DART',
|
||||
it('should contain a default value of "/" when nothing is provided',
|
||||
inject([UrlResolver], (resolver: UrlResolver) => {
|
||||
if (IS_DART) {
|
||||
expect(resolver.resolve(null, 'package:file')).toEqual('/packages/file');
|
||||
}
|
||||
}));
|
||||
|
||||
it('should contain a default value of "/" when nothing is provided for TS/ESM',
|
||||
inject([UrlResolver], (resolver: UrlResolver) => {
|
||||
if (!IS_DART) {
|
||||
expect(resolver.resolve(null, 'package:file')).toEqual('/file');
|
||||
}
|
||||
expect(resolver.resolve(null, 'package:file')).toEqual('/file');
|
||||
}));
|
||||
|
||||
it('should resolve a package value when present within the baseurl', () => {
|
||||
|
|
|
@ -11,7 +11,7 @@ import {ComponentFixture, ComponentFixtureNoNgZone, TestBed, TestComponentBuilde
|
|||
|
||||
import {DirectiveResolver} from '../index';
|
||||
import {MapWrapper} from '../src/facade/collection';
|
||||
import {ConcreteType, IS_DART, Type, isPresent} from '../src/facade/lang';
|
||||
import {ConcreteType, Type, isPresent} from '../src/facade/lang';
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {ObservableWrapper, PromiseCompleter, PromiseWrapper} from '../src/facade/async';
|
||||
import {ListWrapper} from '../src/facade/collection';
|
||||
import {BaseException, ExceptionHandler, unimplemented} from '../src/facade/exceptions';
|
||||
import {ConcreteType, IS_DART, Type, isBlank, isPresent, isPromise} from '../src/facade/lang';
|
||||
import {ConcreteType, Type, isBlank, isPresent, isPromise} from '../src/facade/lang';
|
||||
|
||||
import {APP_INITIALIZER, PLATFORM_INITIALIZER} from './application_tokens';
|
||||
import {ChangeDetectorRef} from './change_detection/change_detector_ref';
|
||||
|
@ -507,9 +507,8 @@ export class ApplicationRef_ extends ApplicationRef {
|
|||
|
||||
this._loadComponent(compRef);
|
||||
if (isDevMode()) {
|
||||
let prodDescription = IS_DART ? 'Production mode is disabled in Dart.' :
|
||||
'Call enableProdMode() to enable the production mode.';
|
||||
this._console.log(`Angular 2 is running in the development mode. ${prodDescription}`);
|
||||
this._console.log(
|
||||
`Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.`);
|
||||
}
|
||||
return compRef;
|
||||
});
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
import {Injector} from '@angular/core';
|
||||
import {beforeEach, ddescribe, describe, expect, iit, it} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {IS_DART} from '../../src/facade/lang';
|
||||
|
||||
export function main() {
|
||||
describe('Injector.NULL', () => {
|
||||
it('should throw if no arg is given', () => {
|
||||
|
|
|
@ -21,7 +21,7 @@ import {DomRootRenderer} from '@angular/platform-browser/src/dom/dom_renderer';
|
|||
import {EventEmitter} from '../../src/facade/async';
|
||||
import {StringMapWrapper} from '../../src/facade/collection';
|
||||
import {BaseException} from '../../src/facade/exceptions';
|
||||
import {ConcreteType, IS_DART, NumberWrapper, Type, isBlank} from '../../src/facade/lang';
|
||||
import {ConcreteType, NumberWrapper, Type, isBlank} from '../../src/facade/lang';
|
||||
|
||||
export function main() {
|
||||
let tcb: TestComponentBuilder;
|
||||
|
@ -133,8 +133,7 @@ export function main() {
|
|||
}));
|
||||
|
||||
it('should support == operations on coerceible', fakeAsync(() => {
|
||||
var expectedValue = IS_DART ? 'false' : 'true';
|
||||
expect(_bindAndCheckSimpleValue('1 == true')).toEqual([`someProp=${expectedValue}`]);
|
||||
expect(_bindAndCheckSimpleValue('1 == true')).toEqual([`someProp=true`]);
|
||||
}));
|
||||
|
||||
it('should support === operations on identical', fakeAsync(() => {
|
||||
|
|
|
@ -16,7 +16,7 @@ import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe
|
|||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
||||
import {BaseException} from '../../src/facade/exceptions';
|
||||
import {ConcreteType, IS_DART, Type, stringify} from '../../src/facade/lang';
|
||||
import {ConcreteType, Type, stringify} from '../../src/facade/lang';
|
||||
|
||||
class Engine {}
|
||||
|
||||
|
@ -105,13 +105,9 @@ class DummyConsole implements Console {
|
|||
}
|
||||
|
||||
export function main() {
|
||||
if (IS_DART) {
|
||||
declareTests({useJit: false});
|
||||
} else {
|
||||
describe('jit', () => { declareTests({useJit: true}); });
|
||||
describe('jit', () => { declareTests({useJit: true}); });
|
||||
|
||||
describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
describe('no jit', () => { declareTests({useJit: false}); });
|
||||
}
|
||||
|
||||
function declareTests({useJit}: {useJit: boolean}) {
|
||||
|
|
|
@ -11,7 +11,6 @@ import {OnInit} from '@angular/core';
|
|||
import {Reflector, ReflectionInfo} from '@angular/core/src/reflection/reflection';
|
||||
import {ReflectionCapabilities} from '@angular/core/src/reflection/reflection_capabilities';
|
||||
import {ClassDecorator, ParamDecorator, PropDecorator, classDecorator, paramDecorator, propDecorator, HasGetterAndSetterDecorators} from './reflector_common';
|
||||
import {IS_DART} from '../../src/facade/lang';
|
||||
import {browserDetection} from '@angular/platform-browser/testing/browser_util';
|
||||
|
||||
class AType {
|
||||
|
@ -188,13 +187,6 @@ export function main() {
|
|||
reflector.registerType(TestObj, new ReflectionInfo(null, null, null, null, {'a': [1, 2]}));
|
||||
expect(reflector.propMetadata(TestObj)).toEqual({'a': [1, 2]});
|
||||
});
|
||||
|
||||
if (IS_DART) {
|
||||
it('should merge metadata from getters and setters', () => {
|
||||
var p = reflector.propMetadata(HasGetterAndSetterDecorators);
|
||||
expect(p['a']).toEqual([propDecorator('get'), propDecorator('set')]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('annotations', () => {
|
||||
|
@ -214,28 +206,6 @@ export function main() {
|
|||
});
|
||||
});
|
||||
|
||||
if (IS_DART) {
|
||||
describe('interfaces', () => {
|
||||
it('should return an array of interfaces for a type', () => {
|
||||
var p = reflector.interfaces(ClassImplementingInterface);
|
||||
expect(p).toEqual([Interface, Interface2]);
|
||||
});
|
||||
|
||||
it('should return an empty array otherwise', () => {
|
||||
var p = reflector.interfaces(ClassWithDecorators);
|
||||
expect(p).toEqual([]);
|
||||
});
|
||||
|
||||
it('should throw for undeclared lifecycle interfaces',
|
||||
() => { expect(() => reflector.interfaces(ClassDoesNotDeclareOnInit)).toThrowError(); });
|
||||
|
||||
it('should throw for class inheriting a lifecycle impl and not declaring the interface',
|
||||
() => {
|
||||
expect(() => reflector.interfaces(SubClassDoesNotDeclareOnInit)).toThrowError();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe('getter', () => {
|
||||
it('returns a function reading a property', () => {
|
||||
var getA = reflector.getter('a');
|
||||
|
@ -280,16 +250,6 @@ export function main() {
|
|||
expect(reflector.method('abc')('anything', ['fake'])).toEqual(['fake']);
|
||||
});
|
||||
});
|
||||
|
||||
if (IS_DART) {
|
||||
describe('importUri', () => {
|
||||
it('should return the importUri for a type', () => {
|
||||
expect(reflector.importUri(TestObjWith00Args)
|
||||
.endsWith('test/core/reflection/reflector_spec.dart'))
|
||||
.toBe(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {AnimationEntryMetadata, Compiler, ComponentFactory, Injectable, Injector, NgZone, OpaqueToken, ViewMetadata} from '../index';
|
||||
import {PromiseWrapper} from '../src/facade/async';
|
||||
import {ConcreteType, IS_DART, Type, isPresent} from '../src/facade/lang';
|
||||
import {ConcreteType, Type, isPresent} from '../src/facade/lang';
|
||||
|
||||
import {ComponentFixture} from './component_fixture';
|
||||
import {tick} from './fake_async';
|
||||
|
@ -103,7 +103,7 @@ export class TestComponentBuilder {
|
|||
* Builds and returns a ComponentFixture.
|
||||
*/
|
||||
createAsync<T>(rootComponentType: ConcreteType<T>): Promise<ComponentFixture<T>> {
|
||||
let noNgZone = IS_DART || this._injector.get(ComponentFixtureNoNgZone, false);
|
||||
let noNgZone = this._injector.get(ComponentFixtureNoNgZone, false);
|
||||
let ngZone: NgZone = noNgZone ? null : this._injector.get(NgZone, null);
|
||||
let compiler: Compiler = this._injector.get(Compiler);
|
||||
|
||||
|
@ -130,7 +130,7 @@ export class TestComponentBuilder {
|
|||
}
|
||||
|
||||
createSync<T>(rootComponentType: ConcreteType<T>): ComponentFixture<T> {
|
||||
let noNgZone = IS_DART || this._injector.get(ComponentFixtureNoNgZone, false);
|
||||
let noNgZone = this._injector.get(ComponentFixtureNoNgZone, false);
|
||||
let ngZone: NgZone = noNgZone ? null : this._injector.get(NgZone, null);
|
||||
let compiler: Compiler = this._injector.get(Compiler);
|
||||
|
||||
|
|
|
@ -51,8 +51,6 @@ export function scheduleMicroTask(fn: Function) {
|
|||
Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
|
||||
}
|
||||
|
||||
export const IS_DART = false;
|
||||
|
||||
// Need to declare a new variable for global here since TypeScript
|
||||
// exports the original value of the symbol.
|
||||
var _global: BrowserNodeGlobal = globalScope;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {AsyncTestCompleter, describe, it, iit, ddescribe, expect, inject, beforeEach,} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {PromiseWrapper} from '../src/facade/async';
|
||||
import {Type, IS_DART} from '../src/facade/lang';
|
||||
import {Type} from '../src/facade/lang';
|
||||
|
||||
import {RouteRegistry} from '../src/route_registry';
|
||||
import {RouteConfig, Route, Redirect, AuxRoute, AsyncRoute} from '../src/route_config/route_config_decorator';
|
||||
|
@ -256,12 +256,8 @@ export function main() {
|
|||
expect(() => registry.config(RootHostCmp, new AuxRoute({path: '/', component: null})))
|
||||
.toThrowError('Component for route "/" is not defined, or is not a class.');
|
||||
|
||||
// This would never happen in Dart
|
||||
if (!IS_DART) {
|
||||
expect(
|
||||
() => registry.config(RootHostCmp, new Route({path: '/', component: <Type>(<any>4)})))
|
||||
.toThrowError('Component for route "/" is not defined, or is not a class.');
|
||||
}
|
||||
expect(() => registry.config(RootHostCmp, new Route({path: '/', component: <Type>(<any>4)})))
|
||||
.toThrowError('Component for route "/" is not defined, or is not a class.');
|
||||
});
|
||||
|
||||
it('should throw when linkParams are not terminal', () => {
|
||||
|
|
Loading…
Reference in New Issue