Skip to content

Commit

Permalink
refactor: Remove isDart from public API
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

- `IS_DARTIUM` no longer exported
  • Loading branch information
mhevery committed Aug 13, 2015
1 parent 5c328ad commit b783738
Show file tree
Hide file tree
Showing 35 changed files with 61 additions and 74 deletions.
6 changes: 3 additions & 3 deletions modules/angular2/src/core/application_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions modules/angular2/src/core/platform_bindings.dart
Original file line number Diff line number Diff line change
@@ -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 []);
6 changes: 6 additions & 0 deletions modules/angular2/src/core/platform_bindings.ts
Original file line number Diff line number Diff line change
@@ -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), []);
2 changes: 0 additions & 2 deletions modules/angular2/src/facade/lang.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions modules/angular2/src/facade/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand Down
2 changes: 0 additions & 2 deletions modules/angular2/src/test_lib/test_lib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions modules/angular2/src/test_lib/test_lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
19 changes: 5 additions & 14 deletions modules/angular2/test/change_detection/change_detector_spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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());

Expand All @@ -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`, () => {

Expand Down Expand Up @@ -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}`]);
});

Expand Down
5 changes: 3 additions & 2 deletions modules/angular2/test/change_detection/parser/parser_spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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) {}
Expand Down Expand Up @@ -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();
});
Expand Down
8 changes: 4 additions & 4 deletions modules/angular2/test/core/application_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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!'})
Expand Down Expand Up @@ -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)]);
Expand All @@ -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)]);
Expand Down
1 change: 0 additions & 1 deletion modules/angular2/test/core/compiler/compiler_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
it,
SpyObject,
proxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
it,
SpyObject,
proxy
Expand Down
6 changes: 3 additions & 3 deletions modules/angular2/test/core/compiler/integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
beforeEachBindings,
it,
xit,
Expand Down Expand Up @@ -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'));

Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
beforeEachBindings,
it,
xit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
it,
SpyObject,
proxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import {
it,
xdescribe,
xit,
TestComponentBuilder,
IS_DARTIUM
TestComponentBuilder
} from 'angular2/test_lib';

import {Directive, Component, View, LifecycleEvent} from 'angular2/angular2';
Expand Down
3 changes: 1 addition & 2 deletions modules/angular2/test/core/exception_handler_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
it,
xdescribe,
xit,
IS_DARTIUM,
Log
} from 'angular2/test_lib';
import {BaseException} from 'angular2/src/facade/lang';
Expand Down Expand Up @@ -91,4 +90,4 @@ export function main() {
});
});
});
}
}
1 change: 0 additions & 1 deletion modules/angular2/test/debug/debug_element_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
beforeEachBindings,
it,
xit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
beforeEachBindings,
it,
xit,
Expand All @@ -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: []})
Expand Down Expand Up @@ -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, '')
Expand Down
6 changes: 3 additions & 3 deletions modules/angular2/test/directives/ng_if_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
expect,
iit,
inject,
IS_DARTIUM,
it,
xit,
} from 'angular2/test_lib';
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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>';
Expand Down Expand Up @@ -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>';
Expand Down
3 changes: 1 addition & 2 deletions modules/angular2/test/facade/async_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 1 addition & 2 deletions modules/angular2/test/pipes/json_pipe_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
3 changes: 3 additions & 0 deletions modules/angular2/test/platform.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library angular2.test.platform;

const IS_DART = true;
1 change: 1 addition & 0 deletions modules/angular2/test/platform.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const IS_DART = false;
Loading

0 comments on commit b783738

Please sign in to comment.