refactor: Remove isDart from public API

BREAKING CHANGE:

- `IS_DARTIUM` no longer exported
This commit is contained in:
Misko Hevery 2015-08-11 14:00:54 -07:00
parent 5c328adb4b
commit b7837389d7
35 changed files with 61 additions and 74 deletions

View File

@ -7,8 +7,7 @@ import {
BaseException,
assertionsEnabled,
print,
stringify,
isDart
stringify
} from 'angular2/src/facade/lang';
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
import {DOM} from 'angular2/src/dom/dom_adapter';
@ -76,6 +75,7 @@ import {
import {internalView} from 'angular2/src/core/compiler/view_ref';
import {APP_COMPONENT_REF_PROMISE, APP_COMPONENT} from './application_tokens';
import {wtfInit} from '../profile/wtf_init';
import {EXCEPTION_BINDING} from './platform_bindings';
var _rootInjector: Injector;
@ -146,7 +146,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
PipeResolver,
Parser,
Lexer,
bind(ExceptionHandler).toFactory(() => new ExceptionHandler(DOM, isDart ? false : true), []),
EXCEPTION_BINDING,
bind(XHR).toValue(new XHRImpl()),
ComponentUrlMapper,
UrlResolver,

View File

@ -0,0 +1,10 @@
library angular2.platform_bindings;
import 'package:angular2/di.dart';
import './exception_handler.dart';
import 'package:angular2/src/dom/dom_adapter.dart';
exceptionFactory() => new ExceptionHandler(DOM, true);
const EXCEPTION_BINDING = const Binding(ExceptionHandler, toFactory: exceptionFactory, deps: const []);

View File

@ -0,0 +1,6 @@
import {bind} from 'angular2/di';
import {ExceptionHandler} from './exception_handler';
import {DOM} from 'angular2/src/dom/dom_adapter';
export const EXCEPTION_BINDING =
bind(ExceptionHandler).toFactory(() => new ExceptionHandler(DOM, false), []);

View File

@ -5,8 +5,6 @@ import 'dart:math' as math;
import 'dart:convert' as convert;
import 'dart:async' show Future;
bool isDart = true;
String getTypeNameForDebugging(Type type) => type.toString();
class Math {

View File

@ -15,8 +15,6 @@ export function getTypeNameForDebugging(type: Type): string {
return type['name'];
}
export var isDart = false;
export class BaseException extends Error {
stack;
constructor(public message?: string, private _originalException?, private _originalStack?,

View File

@ -28,8 +28,6 @@ import 'package:angular2/src/facade/collection.dart' show StringMapWrapper;
import 'test_injector.dart';
export 'test_injector.dart' show inject;
bool IS_DARTIUM = true;
List _testBindings = [];
Injector _injector;
bool _isCurrentTestAsync;

View File

@ -33,9 +33,6 @@ export interface NgMatchers extends jasmine.Matchers {
export var expect: (actual: any) => NgMatchers = <any>_global.expect;
// TODO vsavkin: remove it and use lang/isDart instead
export var IS_DARTIUM = false;
export class AsyncTestCompleter {
_done: Function;

View File

@ -1,15 +1,5 @@
///<reference path="../../src/change_detection/pipe_transform.ts"/>
import {
ddescribe,
describe,
it,
iit,
xit,
expect,
beforeEach,
afterEach,
IS_DARTIUM
} from 'angular2/test_lib';
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach} from 'angular2/test_lib';
import {
CONST_EXPR,
@ -51,6 +41,7 @@ import {JitProtoChangeDetector} from 'angular2/src/change_detection/jit_proto_ch
import {getDefinition} from './change_detector_config';
import {getFactoryById} from './generated/change_detector_classes';
import {IS_DART} from '../platform';
const _DEFAULT_CONTEXT = CONST_EXPR(new Object());
@ -68,8 +59,8 @@ const _DEFAULT_CONTEXT = CONST_EXPR(new Object());
*/
export function main() {
ListWrapper.forEach(['dynamic', 'JIT', 'Pregen'], (cdType) => {
if (cdType == "JIT" && IS_DARTIUM) return;
if (cdType == "Pregen" && !IS_DARTIUM) return;
if (cdType == "JIT" && IS_DART) return;
if (cdType == "Pregen" && !IS_DART) return;
describe(`${cdType} Change Detector`, () => {
@ -141,7 +132,7 @@ export function main() {
() => { expect(_bindSimpleValue('1 != 1')).toEqual(['propName=false']); });
it('should support == operations on coerceible', () => {
var expectedValue = IS_DARTIUM ? 'false' : 'true';
var expectedValue = IS_DART ? 'false' : 'true';
expect(_bindSimpleValue('1 == true')).toEqual([`propName=${expectedValue}`]);
});

View File

@ -1,4 +1,4 @@
import {ddescribe, describe, it, xit, iit, expect, beforeEach, IS_DARTIUM} from 'angular2/test_lib';
import {ddescribe, describe, it, xit, iit, expect, beforeEach} from 'angular2/test_lib';
import {BaseException, isBlank, isPresent} from 'angular2/src/facade/lang';
import {reflector} from 'angular2/src/reflection/reflection';
import {MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
@ -7,6 +7,7 @@ import {Unparser} from './unparser';
import {Lexer} from 'angular2/src/change_detection/parser/lexer';
import {Locals} from 'angular2/src/change_detection/parser/locals';
import {BindingPipe, LiteralPrimitive, AST} from 'angular2/src/change_detection/parser/ast';
import {IS_DART} from '../../platform';
class TestData {
constructor(public a?: any, public b?: any, public fnReturnValue?: any) {}
@ -224,7 +225,7 @@ export function main() {
expect(() => { expectEval('null?.a.a', td()).toEqual(null); }).toThrowError();
});
if (!IS_DARTIUM) {
if (!IS_DART) {
it('should return null when accessing a field on undefined', () => {
expect(() => { expectEval('_undefined?.a', td()).toEqual(null); }).not.toThrow();
});

View File

@ -8,8 +8,7 @@ import {
inject,
it,
xdescribe,
xit,
IS_DARTIUM
xit
} from 'angular2/test_lib';
import {isPresent, stringify} from 'angular2/src/facade/lang';
import {bootstrap, ApplicationRef} from 'angular2/src/core/application';
@ -21,6 +20,7 @@ import {LifeCycle} from 'angular2/core';
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability';
import {DOCUMENT} from 'angular2/src/render/render';
import {IS_DART} from '../platform';
@Component({selector: 'hello-app'})
@View({template: '{{greeting}} world!'})
@ -109,7 +109,7 @@ export function main() {
it('should throw if no element is found', inject([AsyncTestCompleter], (async) => {
var logger = new _ArrayLogger();
var exceptionHandler = new ExceptionHandler(logger, IS_DARTIUM ? false : true);
var exceptionHandler = new ExceptionHandler(logger, IS_DART ? false : true);
var refPromise =
bootstrap(HelloRootCmp, [bind(ExceptionHandler).toValue(exceptionHandler)]);
@ -124,7 +124,7 @@ export function main() {
it('should invoke the default exception handler when bootstrap fails',
inject([AsyncTestCompleter], (async) => {
var logger = new _ArrayLogger();
var exceptionHandler = new ExceptionHandler(logger, IS_DARTIUM ? false : true);
var exceptionHandler = new ExceptionHandler(logger, IS_DART ? false : true);
var refPromise =
bootstrap(HelloRootCmp, [bind(ExceptionHandler).toValue(exceptionHandler)]);

View File

@ -8,7 +8,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
it,
SpyObject,
proxy

View File

@ -8,7 +8,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
it,
SpyObject,
proxy

View File

@ -9,7 +9,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
beforeEachBindings,
it,
xit,
@ -78,6 +77,7 @@ import {ElementRef} from 'angular2/src/core/compiler/element_ref';
import {TemplateRef} from 'angular2/src/core/compiler/template_ref';
import {DomRenderer} from 'angular2/src/render/dom/dom_renderer';
import {IS_DART} from '../../platform';
const ANCHOR_ELEMENT = CONST_EXPR(new OpaqueToken('AnchorElement'));
@ -1330,7 +1330,7 @@ export function main() {
})));
}
if (!IS_DARTIUM) {
if (!IS_DART) {
it('should report a meaningful error when a directive is undefined',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
async) => {
@ -1431,7 +1431,7 @@ export function main() {
}));
describe('Property bindings', () => {
if (!IS_DARTIUM) {
if (!IS_DART) {
it('should throw on bindings to unknown properties',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
async) => {

View File

@ -9,7 +9,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
beforeEachBindings,
it,
xit,

View File

@ -8,7 +8,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
it,
SpyObject,
proxy

View File

@ -9,8 +9,7 @@ import {
it,
xdescribe,
xit,
TestComponentBuilder,
IS_DARTIUM
TestComponentBuilder
} from 'angular2/test_lib';
import {Directive, Component, View, LifecycleEvent} from 'angular2/angular2';

View File

@ -9,7 +9,6 @@ import {
it,
xdescribe,
xit,
IS_DARTIUM,
Log
} from 'angular2/test_lib';
import {BaseException} from 'angular2/src/facade/lang';
@ -91,4 +90,4 @@ export function main() {
});
});
});
}
}

View File

@ -8,7 +8,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
beforeEachBindings,
it,
xit,

View File

@ -8,7 +8,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
beforeEachBindings,
it,
xit,
@ -17,17 +16,15 @@ import {
Scope,
inspectNativeElement
} from 'angular2/test_lib';
import {global} from 'angular2/src/facade/lang';
import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/compiler/view_pool';
import {Injectable, bind} from 'angular2/di';
import {
Directive,
Component,
View,
} from 'angular2/annotations';
import {IS_DART} from '../platform';
@Component({selector: 'my-comp'})
@View({directives: []})
@ -65,7 +62,7 @@ export function main() {
}));
if (!IS_DARTIUM) {
if (!IS_DART) {
it('should provide a global function to inspect elements',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => {
tcb.overrideTemplate(MyComp, '')

View File

@ -9,7 +9,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
it,
xit,
} from 'angular2/test_lib';
@ -19,6 +18,7 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
import {Component, View} from 'angular2/angular2';
import {NgIf} from 'angular2/src/directives/ng_if';
import {IS_DART} from '../platform';
export function main() {
describe('ng-if directive', () => {
@ -146,7 +146,7 @@ export function main() {
}));
if (!IS_DARTIUM) {
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) => {
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';
@ -187,7 +187,7 @@ export function main() {
}));
}
if (IS_DARTIUM) {
if (IS_DART) {
it('should not create the element if the condition is not a boolean (DART)',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
var html = '<div><copy-me template="ng-if numberCondition">hello</copy-me></div>';

View File

@ -9,8 +9,7 @@ import {
el,
SpyObject,
AsyncTestCompleter,
inject,
IS_DARTIUM
inject
} from 'angular2/test_lib';
import {ObservableWrapper, EventEmitter, PromiseWrapper} from 'angular2/src/facade/async';

View File

@ -10,8 +10,7 @@ import {
AsyncTestCompleter,
inject,
proxy,
SpyObject,
IS_DARTIUM
SpyObject
} from 'angular2/test_lib';
import {Json, RegExp, NumberWrapper, StringWrapper} from 'angular2/src/facade/lang';

View File

@ -0,0 +1,3 @@
library angular2.test.platform;
const IS_DART = true;

View File

@ -0,0 +1 @@
export const IS_DART = false;

View File

@ -1,8 +1,9 @@
import {describe, it, iit, ddescribe, expect, beforeEach, IS_DARTIUM} from 'angular2/test_lib';
import {describe, it, iit, ddescribe, expect, beforeEach} from 'angular2/test_lib';
import {Reflector, ReflectionInfo} from 'angular2/src/reflection/reflection';
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
import {ClassDecorator, ParamDecorator, classDecorator, paramDecorator} from './reflector_common';
import {List} from 'angular2/src/facade/collection';
import {IS_DART} from '../platform';
class AType {
value;
@ -132,7 +133,7 @@ export function main() {
});
});
if (IS_DARTIUM) {
if (IS_DART) {
describe("interfaces", () => {
it("should return an array of interfaces for a type", () => {
var p = reflector.interfaces(ClassImplementingInterface);

View File

@ -7,7 +7,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
it,
} from 'angular2/test_lib';

View File

@ -7,9 +7,9 @@ import {
iit,
inject,
it,
xit,
IS_DARTIUM
xit
} from 'angular2/test_lib';
import {IS_DART} from '../../../platform';
import {DomElementSchemaRegistry} from 'angular2/src/render/dom/schema/dom_element_schema_registry';
import {DOM} from 'angular2/src/dom/dom_adapter';
@ -17,7 +17,7 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
export function main() {
// DOMElementSchema can only be used on the JS side where we can safely
// use reflection for DOM elements
if (IS_DARTIUM) return;
if (IS_DART) return;
var registry;

View File

@ -7,8 +7,7 @@ import {
xdescribe,
expect,
beforeEach,
el,
IS_DARTIUM
el
} from 'angular2/test_lib';
import {DomElementSchemaRegistry} from 'angular2/src/render/dom/schema/dom_element_schema_registry';
@ -17,6 +16,7 @@ import {ProtoViewBuilder} from 'angular2/src/render/dom/view/proto_view_builder'
import {ASTWithSource, AST} from 'angular2/src/change_detection/change_detection';
import {PropertyBindingType, ViewType, ViewEncapsulation} from 'angular2/src/render/api';
import {DOM} from 'angular2/src/dom/dom_adapter';
import {IS_DART} from '../../../platform';
export function main() {
function emptyExpr() { return new ASTWithSource(new AST(), 'empty', 'empty'); }
@ -30,7 +30,7 @@ export function main() {
new ProtoViewBuilder(DOM.createTemplate(''), ViewType.EMBEDDED, ViewEncapsulation.NONE);
});
if (!IS_DARTIUM) {
if (!IS_DART) {
describe('verification of properties', () => {
it('should throw for unknown properties', () => {

View File

@ -7,7 +7,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
it,
} from 'angular2/test_lib';
import {MockXHR} from 'angular2/src/render/xhr_mock';

View File

@ -7,8 +7,7 @@ import {
expect,
inject,
beforeEach,
SpyObject,
IS_DARTIUM
SpyObject
} from 'angular2/test_lib';
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
@ -17,6 +16,7 @@ import {Type} from 'angular2/src/facade/lang';
import {RouteRegistry} from 'angular2/src/router/route_registry';
import {RouteConfig, Route, AuxRoute, AsyncRoute} from 'angular2/src/router/route_config_decorator';
import {stringifyInstruction} from 'angular2/src/router/instruction';
import {IS_DART} from '../platform';
export function main() {
describe('RouteRegistry', () => {
@ -195,7 +195,7 @@ export function main() {
.toThrowError('Component for route "/" is not defined, or is not a class.');
// This would never happen in Dart
if (!IS_DARTIUM) {
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.');
}

View File

@ -8,7 +8,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
beforeEachBindings,
it,
xit,

View File

@ -8,7 +8,6 @@ import {
flushMicrotasks,
iit,
inject,
IS_DARTIUM,
it,
Log,
tick,

View File

@ -8,7 +8,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
beforeEachBindings,
it,
xit,

View File

@ -1,4 +1,4 @@
import {ddescribe, describe, it, iit, expect, IS_DARTIUM} from 'angular2/test_lib';
import {ddescribe, describe, it, iit, expect} from 'angular2/test_lib';
import {IMPLEMENTS} from './fixtures/annotations';
class Interface1 {

View File

@ -1,4 +1,4 @@
import {describe, xdescribe, it, expect, IS_DARTIUM} from 'angular2/test_lib';
import {describe, xdescribe, it, expect} from 'angular2/test_lib';
class A {}
class B {}