refactor: remove lang.ts (#14837)
This commit is contained in:

committed by
Chuck Jazdzewski

parent
84a65cf788
commit
8343fb7740
@ -8,7 +8,6 @@
|
||||
|
||||
import {describe, expect, it} from '../../../core/testing/testing_internal';
|
||||
import {CssLexer, CssLexerMode, CssToken, CssTokenType, cssScannerError, getRawMessage, getToken} from '../../src/css_parser/css_lexer';
|
||||
import {isPresent} from '../../src/facade/lang';
|
||||
|
||||
export function main() {
|
||||
function tokenize(
|
||||
@ -21,7 +20,7 @@ export function main() {
|
||||
let output = scanner.scan();
|
||||
while (output != null) {
|
||||
const error = output.error;
|
||||
if (isPresent(error)) {
|
||||
if (error != null) {
|
||||
throw cssScannerError(getToken(error), getRawMessage(error));
|
||||
}
|
||||
tokens.push(output.token);
|
||||
|
@ -10,7 +10,6 @@
|
||||
import {beforeEach, describe, expect, it} from '../../../core/testing/testing_internal';
|
||||
import {CssAst, CssAstVisitor, CssAtRulePredicateAst, CssBlockAst, CssDefinitionAst, CssInlineRuleAst, CssKeyframeDefinitionAst, CssKeyframeRuleAst, CssMediaQueryRuleAst, CssPseudoSelectorAst, CssRuleAst, CssSelectorAst, CssSelectorRuleAst, CssSimpleSelectorAst, CssStyleSheetAst, CssStyleValueAst, CssStylesBlockAst, CssUnknownRuleAst, CssUnknownTokenListAst} from '../../src/css_parser/css_ast';
|
||||
import {BlockType, CssParseError, CssParser, CssToken} from '../../src/css_parser/css_parser';
|
||||
import {isPresent} from '../../src/facade/lang';
|
||||
|
||||
function _assertTokens(tokens: CssToken[], valuesArr: string[]): void {
|
||||
expect(tokens.length).toEqual(valuesArr.length);
|
||||
|
@ -11,7 +11,6 @@ import {Lexer} from '@angular/compiler/src/expression_parser/lexer';
|
||||
import {Parser, SplitInterpolation, TemplateBindingParseResult} from '@angular/compiler/src/expression_parser/parser';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
||||
import {isBlank, isPresent} from '../../src/facade/lang';
|
||||
|
||||
import {unparse} from './unparser';
|
||||
import {validate} from './validator';
|
||||
@ -50,21 +49,21 @@ export function main() {
|
||||
|
||||
function checkInterpolation(exp: string, expected?: string) {
|
||||
const ast = parseInterpolation(exp);
|
||||
if (isBlank(expected)) expected = exp;
|
||||
if (expected == null) expected = exp;
|
||||
expect(unparse(ast)).toEqual(expected);
|
||||
validate(ast);
|
||||
}
|
||||
|
||||
function checkBinding(exp: string, expected?: string) {
|
||||
const ast = parseBinding(exp);
|
||||
if (isBlank(expected)) expected = exp;
|
||||
if (expected == null) expected = exp;
|
||||
expect(unparse(ast)).toEqual(expected);
|
||||
validate(ast);
|
||||
}
|
||||
|
||||
function checkAction(exp: string, expected?: string) {
|
||||
const ast = parseAction(exp);
|
||||
if (isBlank(expected)) expected = exp;
|
||||
if (expected == null) expected = exp;
|
||||
expect(unparse(ast)).toEqual(expected);
|
||||
validate(ast);
|
||||
}
|
||||
@ -321,9 +320,9 @@ export function main() {
|
||||
function keyValues(templateBindings: any[]) {
|
||||
return templateBindings.map(binding => {
|
||||
if (binding.keyIsVar) {
|
||||
return 'let ' + binding.key + (isBlank(binding.name) ? '=null' : '=' + binding.name);
|
||||
return 'let ' + binding.key + (binding.name == null ? '=null' : '=' + binding.name);
|
||||
} else {
|
||||
return binding.key + (isBlank(binding.expression) ? '' : `=${binding.expression}`);
|
||||
return binding.key + (binding.expression == null ? '' : `=${binding.expression}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -335,7 +334,7 @@ export function main() {
|
||||
|
||||
function exprSources(templateBindings: any[]) {
|
||||
return templateBindings.map(
|
||||
binding => isPresent(binding.expression) ? binding.expression.source : null);
|
||||
binding => binding.expression != null ? binding.expression.source : null);
|
||||
}
|
||||
|
||||
it('should parse an empty string', () => { expect(parseTemplateBindings('')).toEqual([]); });
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {escapeRegExp} from '@angular/core/src/facade/lang';
|
||||
import {escapeRegExp} from '@angular/compiler/src/util';
|
||||
|
||||
import {serializeNodes} from '../../../src/i18n/digest';
|
||||
import {MessageBundle} from '../../../src/i18n/message_bundle';
|
||||
|
@ -6,8 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {escapeRegExp} from '@angular/core/src/facade/lang';
|
||||
|
||||
import {escapeRegExp} from '@angular/compiler/src/util';
|
||||
import {serializeNodes} from '../../../src/i18n/digest';
|
||||
import * as i18n from '../../../src/i18n/i18n_ast';
|
||||
import {Xtb} from '../../../src/i18n/serializers/xtb';
|
||||
|
@ -7,12 +7,10 @@
|
||||
*/
|
||||
|
||||
import {TEST_COMPILER_PROVIDERS} from '@angular/compiler/testing/test_bindings';
|
||||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, Component, Directive, DoCheck, Injectable, NgModule, OnChanges, OnDestroy, OnInit, Pipe, SimpleChanges, ViewEncapsulation} from '@angular/core';
|
||||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, Component, Directive, DoCheck, Injectable, NgModule, OnChanges, OnDestroy, OnInit, Pipe, SimpleChanges, ViewEncapsulation, ɵstringify as stringify} from '@angular/core';
|
||||
import {LIFECYCLE_HOOKS_VALUES} from '@angular/core/src/metadata/lifecycle_hooks';
|
||||
import {TestBed, async, inject} from '@angular/core/testing';
|
||||
|
||||
import {identifierName} from '../src/compile_metadata';
|
||||
import {stringify} from '../src/facade/lang';
|
||||
import {CompileMetadataResolver} from '../src/metadata_resolver';
|
||||
import {ResourceLoader} from '../src/resource_loader';
|
||||
import {MockResourceLoader} from '../testing/resource_loader_mock';
|
||||
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
import {NgModuleResolver} from '@angular/compiler/src/ng_module_resolver';
|
||||
import {ɵstringify as stringify} from '@angular/core';
|
||||
import {NgModule} from '@angular/core/src/metadata';
|
||||
import {stringify} from '../src/facade/lang';
|
||||
|
||||
class SomeClass1 {}
|
||||
class SomeClass2 {}
|
||||
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
import {PipeResolver} from '@angular/compiler/src/pipe_resolver';
|
||||
import {ɵstringify as stringify} from '@angular/core';
|
||||
import {Pipe} from '@angular/core/src/metadata';
|
||||
import {stringify} from '../src/facade/lang';
|
||||
|
||||
@Pipe({name: 'somePipe', pure: true})
|
||||
class SomePipe {
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
import {MockResourceLoader} from '@angular/compiler/testing/resource_loader_mock';
|
||||
import {AsyncTestCompleter, beforeEach, describe, expect, inject, it} from '@angular/core/testing/testing_internal';
|
||||
import {isPresent} from '../src/facade/lang';
|
||||
|
||||
export function main() {
|
||||
describe('MockResourceLoader', () => {
|
||||
@ -23,7 +22,7 @@ export function main() {
|
||||
throw `Unexpected response ${url} -> ${text}`;
|
||||
} else {
|
||||
expect(text).toEqual(response);
|
||||
if (isPresent(done)) done();
|
||||
if (done != null) done();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
@ -33,7 +32,7 @@ export function main() {
|
||||
throw `Unexpected error ${url}`;
|
||||
} else {
|
||||
expect(error).toEqual(`Failed to load ${url}`);
|
||||
if (isPresent(done)) done();
|
||||
if (done != null) done();
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -7,11 +7,9 @@
|
||||
*/
|
||||
|
||||
import {DirectiveResolver, ResourceLoader} from '@angular/compiler';
|
||||
import {Compiler, Component, Injector, NgModule, NgModuleFactory, ɵViewMetadata as ViewMetadata} from '@angular/core';
|
||||
import {Compiler, Component, Injector, NgModule, NgModuleFactory, ɵViewMetadata as ViewMetadata, ɵstringify as stringify} from '@angular/core';
|
||||
import {TestBed, async, fakeAsync, inject, tick} from '@angular/core/testing';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
||||
import {stringify} from '../src/facade/lang';
|
||||
import {MockDirectiveResolver} from '../testing/index';
|
||||
import {SpyResourceLoader} from './spies';
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {fakeAsync} from '@angular/core/testing/fake_async';
|
||||
import {describe, expect, it} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {SyncAsyncResult, splitAtColon} from '../src/util';
|
||||
import {SyncAsyncResult, escapeRegExp, splitAtColon} from '../src/util';
|
||||
|
||||
export function main() {
|
||||
describe('util', () => {
|
||||
@ -36,5 +36,14 @@ export function main() {
|
||||
expect(splitAtColon('ab', ['c', 'd'])).toEqual(['c', 'd']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('RegExp', () => {
|
||||
it('should escape regexp', () => {
|
||||
expect(new RegExp(escapeRegExp('b')).exec('abc')).toBeTruthy();
|
||||
expect(new RegExp(escapeRegExp('b')).exec('adc')).toBeFalsy();
|
||||
expect(new RegExp(escapeRegExp('a.b')).exec('a.b')).toBeTruthy();
|
||||
expect(new RegExp(escapeRegExp('a.b')).exec('axb')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user