@ -16,7 +16,7 @@ import {MockStaticSymbolResolverHost, MockSummaryResolver} from './static_symbol
|
||||
|
||||
const EXT = /(\.d)?\.ts$/;
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('AotSummaryResolver', () => {
|
||||
let summaryResolver: AotSummaryResolver;
|
||||
let symbolCache: StaticSymbolCache;
|
||||
|
@ -15,7 +15,7 @@ import {MockStaticSymbolResolverHost} from './static_symbol_resolver_spec';
|
||||
import {MockAotSummaryResolverHost, createMockOutputContext} from './summary_resolver_spec';
|
||||
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('summary serializer', () => {
|
||||
let summaryResolver: AotSummaryResolver;
|
||||
let symbolResolver: StaticSymbolResolver;
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {MissingTranslationStrategy} from '@angular/core';
|
||||
import {CompilerConfig} from '../src/config';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('compiler config', () => {
|
||||
it('should set missing translation strategy', () => {
|
||||
const config = new CompilerConfig({missingTranslation: MissingTranslationStrategy.Error});
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {core as compilerCore} from '@angular/compiler';
|
||||
import * as core from '@angular/core';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('compiler core', () => {
|
||||
it('Attribute should be equal', () => {
|
||||
typeExtends<compilerCore.Attribute, core.Attribute>();
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {describe, expect, it} from '../../../core/testing/src/testing_internal';
|
||||
import {CssLexer, CssLexerMode, CssToken, CssTokenType, cssScannerError, getRawMessage, getToken} from '../../src/css_parser/css_lexer';
|
||||
|
||||
export function main() {
|
||||
(function(){
|
||||
function tokenize(
|
||||
code: string, trackComments: boolean = false,
|
||||
mode: CssLexerMode = CssLexerMode.ALL): CssToken[] {
|
||||
@ -373,4 +373,4 @@ export function main() {
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
@ -18,7 +18,7 @@ export function assertTokens(tokens: CssToken[], valuesArr: string[]) {
|
||||
}
|
||||
}
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('CssParser', () => {
|
||||
function parse(css: string): ParsedCssResult {
|
||||
return new CssParser().parse(css, 'some-fake-css-file.css');
|
||||
|
@ -115,7 +115,7 @@ function _getCaptureAst(capture: any[], index = 0): CssAst {
|
||||
return <CssAst>capture[index][0];
|
||||
}
|
||||
|
||||
export function main() {
|
||||
(function(){
|
||||
function parse(cssCode: string, ignoreErrors: boolean = false) {
|
||||
const output = new CssParser().parse(cssCode, 'some-fake-css-file.css');
|
||||
const errors = output.errors;
|
||||
@ -318,4 +318,4 @@ export function main() {
|
||||
_assertTokens(rule.tokens, ['six', 'seven', 'eight']);
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
@ -14,7 +14,7 @@ function hasLifecycleHook(hook: Hooks, directive: any): boolean {
|
||||
return hasLifecycleHookImpl(new JitReflector(), hook, directive);
|
||||
}
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('Create Directive', () => {
|
||||
describe('lifecycle', () => {
|
||||
|
||||
|
@ -42,7 +42,7 @@ function normalizeTemplate(normalizer: DirectiveNormalizer, o: {
|
||||
});
|
||||
}
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('DirectiveNormalizer', () => {
|
||||
let resourceLoaderSpy: jasmine.Spy;
|
||||
|
||||
|
@ -12,7 +12,7 @@ import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_refle
|
||||
|
||||
import {MockDirectiveResolver} from '../testing';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('MockDirectiveResolver', () => {
|
||||
let dirResolver: MockDirectiveResolver;
|
||||
|
||||
|
@ -112,7 +112,7 @@ class SomeDirectiveWithMalformedHostBinding2 {
|
||||
|
||||
class SomeDirectiveWithoutMetadata {}
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('DirectiveResolver', () => {
|
||||
let resolver: DirectiveResolver;
|
||||
|
||||
|
@ -58,7 +58,7 @@ function expectErrorToken(token: Token, index: any, message: string) {
|
||||
expect(token.toString()).toEqual(message);
|
||||
}
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('lexer', () => {
|
||||
describe('token', () => {
|
||||
it('should tokenize a simple identifier', () => {
|
||||
|
@ -15,7 +15,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
import {unparse} from './unparser';
|
||||
import {validate} from './validator';
|
||||
|
||||
export function main() {
|
||||
(function(){
|
||||
function createParser() { return new Parser(new Lexer()); }
|
||||
|
||||
function parseAction(text: string, location: any = null): ASTWithSource {
|
||||
@ -604,4 +604,4 @@ export function main() {
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {computeMsgId, digest, sha1} from '../../src/i18n/digest';
|
||||
|
||||
export function main(): void {
|
||||
{
|
||||
describe('digest', () => {
|
||||
describe('digest', () => {
|
||||
it('must return the ID if it\'s explicit', () => {
|
||||
|
@ -16,7 +16,7 @@ import {TranslationBundle} from '../../src/i18n/translation_bundle';
|
||||
import * as html from '../../src/ml_parser/ast';
|
||||
import {serializeNodes as serializeHtmlNodes} from '../ml_parser/ast_serializer_spec';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('Extractor', () => {
|
||||
describe('elements', () => {
|
||||
it('should extract from elements', () => {
|
||||
|
@ -11,7 +11,7 @@ import {TranslationBundle} from '@angular/compiler/src/i18n/translation_bundle';
|
||||
import {HtmlParser} from '@angular/compiler/src/ml_parser/html_parser';
|
||||
import {ParseTreeResult} from '@angular/compiler/src/ml_parser/parser';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('I18N html parser', () => {
|
||||
// https://github.com/angular/angular/issues/14322
|
||||
it('should parse the translations only once', () => {
|
||||
|
@ -12,7 +12,7 @@ import {Message} from '@angular/compiler/src/i18n/i18n_ast';
|
||||
import {HtmlParser} from '@angular/compiler/src/ml_parser/html_parser';
|
||||
import {DEFAULT_INTERPOLATION_CONFIG} from '@angular/compiler/src/ml_parser/interpolation_config';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('I18nParser', () => {
|
||||
|
||||
describe('elements', () => {
|
||||
|
@ -20,7 +20,7 @@ import {SpyResourceLoader} from '../spies';
|
||||
|
||||
import {FrLocalization, HTML, I18nComponent, validateHtml} from './integration_common';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('i18n XLIFF 2.0 integration spec', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
|
@ -20,7 +20,7 @@ import {SpyResourceLoader} from '../spies';
|
||||
|
||||
import {FrLocalization, HTML, I18nComponent, validateHtml} from './integration_common';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('i18n XLIFF integration spec', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
|
@ -20,7 +20,7 @@ import {SpyResourceLoader} from '../spies';
|
||||
|
||||
import {FrLocalization, HTML, I18nComponent, validateHtml} from './integration_common';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('i18n XMB/XTB integration spec', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
|
@ -13,7 +13,7 @@ import {Serializer} from '../../src/i18n/serializers/serializer';
|
||||
import {HtmlParser} from '../../src/ml_parser/html_parser';
|
||||
import {DEFAULT_INTERPOLATION_CONFIG} from '../../src/ml_parser/interpolation_config';
|
||||
|
||||
export function main(): void {
|
||||
{
|
||||
describe('MessageBundle', () => {
|
||||
describe('Messages', () => {
|
||||
let messages: MessageBundle;
|
||||
|
@ -11,7 +11,7 @@ import * as i18n from '@angular/compiler/src/i18n/i18n_ast';
|
||||
import {serializeNodes} from '../../../src/i18n/digest';
|
||||
import {_extractMessages} from '../i18n_parser_spec';
|
||||
|
||||
export function main(): void {
|
||||
{
|
||||
describe('i18n AST', () => {
|
||||
describe('CloneVisitor', () => {
|
||||
it('should clone an AST', () => {
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {PlaceholderRegistry} from '../../../src/i18n/serializers/placeholder';
|
||||
|
||||
export function main(): void {
|
||||
{
|
||||
describe('PlaceholderRegistry', () => {
|
||||
let reg: PlaceholderRegistry;
|
||||
|
||||
|
@ -242,7 +242,7 @@ lignes</target>
|
||||
</xliff>
|
||||
`;
|
||||
|
||||
export function main(): void {
|
||||
(function(){
|
||||
const serializer = new Xliff2();
|
||||
|
||||
function toXliff(html: string, locale: string | null = null): string {
|
||||
@ -413,4 +413,4 @@ lignes`
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
@ -226,7 +226,7 @@ lignes</target>
|
||||
</xliff>
|
||||
`;
|
||||
|
||||
export function main(): void {
|
||||
(function(){
|
||||
const serializer = new Xliff();
|
||||
|
||||
function toXliff(html: string, locale: string | null = null): string {
|
||||
@ -381,4 +381,4 @@ lignes`
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
@ -11,7 +11,7 @@ import {Xmb} from '@angular/compiler/src/i18n/serializers/xmb';
|
||||
import {HtmlParser} from '@angular/compiler/src/ml_parser/html_parser';
|
||||
import {DEFAULT_INTERPOLATION_CONFIG} from '@angular/compiler/src/ml_parser/interpolation_config';
|
||||
|
||||
export function main(): void {
|
||||
{
|
||||
describe('XMB serializer', () => {
|
||||
const HTML = `
|
||||
<p>not translatable</p>
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import * as xml from '../../../src/i18n/serializers/xml_helper';
|
||||
|
||||
export function main(): void {
|
||||
{
|
||||
describe('XML helper', () => {
|
||||
it('should serialize XML declaration', () => {
|
||||
expect(xml.serialize([new xml.Declaration({version: '1.0'})]))
|
||||
|
@ -12,7 +12,7 @@ import * as i18n from '../../../src/i18n/i18n_ast';
|
||||
import {Xtb} from '../../../src/i18n/serializers/xtb';
|
||||
|
||||
|
||||
export function main(): void {
|
||||
{
|
||||
describe('XTB serializer', () => {
|
||||
const serializer = new Xtb();
|
||||
|
||||
|
@ -14,7 +14,7 @@ import {ParseLocation, ParseSourceFile, ParseSourceSpan} from '../../src/parse_u
|
||||
import {serializeNodes} from '../ml_parser/ast_serializer_spec';
|
||||
import {_extractMessages} from './i18n_parser_spec';
|
||||
|
||||
export function main(): void {
|
||||
{
|
||||
describe('TranslationBundle', () => {
|
||||
const file = new ParseSourceFile('content', 'url');
|
||||
const startLocation = new ParseLocation(file, 0, 0, 0);
|
||||
|
@ -12,7 +12,7 @@ import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {browserDetection} from '@angular/platform-browser/testing/src/browser_util';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('integration tests', () => {
|
||||
let fixture: ComponentFixture<TestComponent>;
|
||||
|
||||
|
@ -18,7 +18,7 @@ import {MockResourceLoader} from '../testing/src/resource_loader_mock';
|
||||
import {MalformedStylesComponent} from './metadata_resolver_fixture';
|
||||
import {TEST_COMPILER_PROVIDERS} from './test_bindings';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('CompileMetadataResolver', () => {
|
||||
beforeEach(() => { TestBed.configureCompiler({providers: TEST_COMPILER_PROVIDERS}); });
|
||||
|
||||
|
@ -10,7 +10,7 @@ import * as html from '@angular/compiler/src/ml_parser/ast';
|
||||
import {HtmlParser} from '@angular/compiler/src/ml_parser/html_parser';
|
||||
import {getHtmlTagDefinition} from '@angular/compiler/src/ml_parser/html_tags';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('Node serializer', () => {
|
||||
let parser: HtmlParser;
|
||||
|
||||
|
@ -13,7 +13,7 @@ import {ParseError} from '../../src/parse_util';
|
||||
|
||||
import {humanizeDom, humanizeDomSourceSpans, humanizeLineColumn} from './ast_spec_utils';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('HtmlParser', () => {
|
||||
let parser: HtmlParser;
|
||||
|
||||
|
@ -12,7 +12,7 @@ import {PRESERVE_WS_ATTR_NAME, removeWhitespaces} from '../../src/ml_parser/html
|
||||
|
||||
import {humanizeDom} from './ast_spec_utils';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('removeWhitespaces', () => {
|
||||
|
||||
function parseAndRemoveWS(template: string): any[] {
|
||||
|
@ -13,7 +13,7 @@ import {ParseError} from '../../src/parse_util';
|
||||
|
||||
import {humanizeNodes} from './ast_spec_utils';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('Expander', () => {
|
||||
function expand(template: string): ExpansionResult {
|
||||
const htmlParser = new HtmlParser();
|
||||
|
@ -11,7 +11,7 @@ import {InterpolationConfig} from '../../src/ml_parser/interpolation_config';
|
||||
import * as lex from '../../src/ml_parser/lexer';
|
||||
import {ParseLocation, ParseSourceFile, ParseSourceSpan} from '../../src/parse_util';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('HtmlLexer', () => {
|
||||
describe('line/column numbers', () => {
|
||||
it('should work without newlines', () => {
|
||||
|
@ -12,7 +12,7 @@ import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_refle
|
||||
|
||||
import {MockNgModuleResolver} from '../testing';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('MockNgModuleResolver', () => {
|
||||
let ngModuleResolver: MockNgModuleResolver;
|
||||
|
||||
|
@ -29,7 +29,7 @@ class SomeModule {
|
||||
|
||||
class SimpleClass {}
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('NgModuleResolver', () => {
|
||||
let resolver: NgModuleResolver;
|
||||
|
||||
|
@ -11,7 +11,7 @@ import {EmitterVisitorContext} from '@angular/compiler/src/output/abstract_emitt
|
||||
import {SourceMap} from '@angular/compiler/src/output/source_map';
|
||||
import {extractSourceMap, originalPositionFor} from '@angular/compiler/testing/src/output/source_map_util';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('AbstractEmitter', () => {
|
||||
describe('EmitterVisitorContext', () => {
|
||||
const fileA = new ParseSourceFile('a0a1a2a3a4a5a6a7a8a9', 'a.js');
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {escapeIdentifier} from '@angular/compiler/src/output/abstract_emitter';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('AbstractEmitter', () => {
|
||||
describe('escapeIdentifier', () => {
|
||||
it('should escape single quotes',
|
||||
|
@ -17,7 +17,7 @@ import {extractSourceMap, originalPositionFor} from '@angular/compiler/testing/s
|
||||
|
||||
const someGenFilePath = 'somePackage/someGenFile';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('JavaScriptEmitter', () => {
|
||||
let emitter: JavaScriptEmitter;
|
||||
let someVar: o.ReadVarExpr;
|
||||
|
@ -19,7 +19,7 @@ const sameModuleIdentifier = new o.ExternalReference(null, 'someLocalId', null);
|
||||
|
||||
const externalModuleIdentifier = new o.ExternalReference(anotherModuleUrl, 'someExternalId', null);
|
||||
|
||||
export function main() {
|
||||
{
|
||||
// Note supported features of our OutputAstin JavaScript / ES5:
|
||||
// - types
|
||||
// - declaring fields
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import * as o from '../../src/output/output_ast';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('OutputAst', () => {
|
||||
describe('collectExternalReferences', () => {
|
||||
it('should find expressions of variable types', () => {
|
||||
|
@ -13,7 +13,7 @@ import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_refle
|
||||
|
||||
const anotherModuleUrl = 'somePackage/someOtherPath';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('Output JIT', () => {
|
||||
describe('regression', () => {
|
||||
it('should generate unique argument names', () => {
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {SourceMapGenerator, toBase64String} from '@angular/compiler/src/output/source_map';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('source map generation', () => {
|
||||
describe('generation', () => {
|
||||
it('should generate a valid source map', () => {
|
||||
|
@ -17,7 +17,7 @@ import {extractSourceMap, originalPositionFor} from '@angular/compiler/testing/s
|
||||
|
||||
const someGenFilePath = 'somePackage/someGenFile';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
// Not supported features of our OutputAst in TS:
|
||||
// - real `const` like in Dart
|
||||
// - final fields
|
||||
|
@ -19,7 +19,7 @@ const sameModuleIdentifier = new o.ExternalReference(null, 'someLocalId', null);
|
||||
|
||||
const externalModuleIdentifier = new o.ExternalReference(anotherModuleUrl, 'someExternalId', null);
|
||||
|
||||
export function main() {
|
||||
{
|
||||
// Not supported features of our OutputAst in TS:
|
||||
// - real `const` like in Dart
|
||||
// - final fields
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {ParseError, ParseErrorLevel, ParseLocation, ParseSourceFile, ParseSourceSpan} from '../src/parse_util';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('ParseError', () => {
|
||||
it('should reflect the level in the message', () => {
|
||||
const file = new ParseSourceFile(`foo\nbar\nfoo`, 'url');
|
||||
|
@ -12,7 +12,7 @@ import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_refle
|
||||
|
||||
import {MockPipeResolver} from '../testing';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('MockPipeResolver', () => {
|
||||
let pipeResolver: MockPipeResolver;
|
||||
|
||||
|
@ -17,7 +17,7 @@ class SomePipe {
|
||||
|
||||
class SimpleClass {}
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('PipeResolver', () => {
|
||||
let resolver: PipeResolver;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {MockResourceLoader} from '@angular/compiler/testing/src/resource_loader_mock';
|
||||
import {AsyncTestCompleter, beforeEach, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('MockResourceLoader', () => {
|
||||
let resourceLoader: MockResourceLoader;
|
||||
|
||||
|
@ -25,7 +25,7 @@ class SomeComp {
|
||||
class SomeCompWithUrlTemplate {
|
||||
}
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('RuntimeCompiler', () => {
|
||||
|
||||
describe('compilerComponentSync', () => {
|
||||
|
@ -16,7 +16,7 @@ import {HtmlParser} from '../../src/ml_parser/html_parser';
|
||||
|
||||
import {extractSchema} from './schema_extractor';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('DOMElementSchema', () => {
|
||||
let registry: DomElementSchemaRegistry;
|
||||
beforeEach(() => { registry = new DomElementSchemaRegistry(); });
|
||||
|
@ -10,7 +10,7 @@ import {CssSelector, SelectorMatcher} from '@angular/compiler/src/selector';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {el} from '@angular/platform-browser/testing/src/browser_util';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('SelectorMatcher', () => {
|
||||
let matcher: SelectorMatcher;
|
||||
let selectableCollector: (selector: CssSelector, context: any) => void;
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {CssRule, ShadowCss, processRules} from '@angular/compiler/src/shadow_css';
|
||||
import {normalizeCSS} from '@angular/platform-browser/testing/src/browser_util';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('ShadowCss', function() {
|
||||
|
||||
function s(css: string, contentAttr: string, hostAttr: string = '') {
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {extractStyleUrls, isStyleUrlResolvable} from '@angular/compiler/src/style_url_resolver';
|
||||
import {UrlResolver} from '@angular/compiler/src/url_resolver';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('extractStyleUrls', () => {
|
||||
let urlResolver: UrlResolver;
|
||||
|
||||
|
@ -12,7 +12,7 @@ import {inject} from '@angular/core/testing';
|
||||
import {ElementSchemaRegistry} from '../../src/schema/element_schema_registry';
|
||||
import {calcPossibleSecurityContexts} from '../../src/template_parser/binding_parser';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('BindingParser', () => {
|
||||
let registry: ElementSchemaRegistry;
|
||||
|
||||
|
@ -116,8 +116,214 @@ function compileTemplateMetadata({encapsulation, template, templateUrl, styles,
|
||||
}
|
||||
|
||||
|
||||
function humanizeTplAst(
|
||||
templateAsts: TemplateAst[], interpolationConfig?: InterpolationConfig): any[] {
|
||||
const humanizer = new TemplateHumanizer(false, interpolationConfig);
|
||||
templateVisitAll(humanizer, templateAsts);
|
||||
return humanizer.result;
|
||||
}
|
||||
|
||||
export function main() {
|
||||
function humanizeTplAstSourceSpans(
|
||||
templateAsts: TemplateAst[], interpolationConfig?: InterpolationConfig): any[] {
|
||||
const humanizer = new TemplateHumanizer(true, interpolationConfig);
|
||||
templateVisitAll(humanizer, templateAsts);
|
||||
return humanizer.result;
|
||||
}
|
||||
|
||||
class TemplateHumanizer implements TemplateAstVisitor {
|
||||
result: any[] = [];
|
||||
|
||||
constructor(
|
||||
private includeSourceSpan: boolean,
|
||||
private interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {}
|
||||
|
||||
visitNgContent(ast: NgContentAst, context: any): any {
|
||||
const res = [NgContentAst];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
||||
const res = [EmbeddedTemplateAst];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
templateVisitAll(this, ast.attrs);
|
||||
templateVisitAll(this, ast.outputs);
|
||||
templateVisitAll(this, ast.references);
|
||||
templateVisitAll(this, ast.variables);
|
||||
templateVisitAll(this, ast.directives);
|
||||
templateVisitAll(this, ast.children);
|
||||
return null;
|
||||
}
|
||||
visitElement(ast: ElementAst, context: any): any {
|
||||
const res = [ElementAst, ast.name];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
templateVisitAll(this, ast.attrs);
|
||||
templateVisitAll(this, ast.inputs);
|
||||
templateVisitAll(this, ast.outputs);
|
||||
templateVisitAll(this, ast.references);
|
||||
templateVisitAll(this, ast.directives);
|
||||
templateVisitAll(this, ast.children);
|
||||
return null;
|
||||
}
|
||||
visitReference(ast: ReferenceAst, context: any): any {
|
||||
const res = [ReferenceAst, ast.name, ast.value];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitVariable(ast: VariableAst, context: any): any {
|
||||
const res = [VariableAst, ast.name, ast.value];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitEvent(ast: BoundEventAst, context: any): any {
|
||||
const res =
|
||||
[BoundEventAst, ast.name, ast.target, unparse(ast.handler, this.interpolationConfig)];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitElementProperty(ast: BoundElementPropertyAst, context: any): any {
|
||||
const res = [
|
||||
BoundElementPropertyAst, ast.type, ast.name, unparse(ast.value, this.interpolationConfig),
|
||||
ast.unit
|
||||
];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitAttr(ast: AttrAst, context: any): any {
|
||||
const res = [AttrAst, ast.name, ast.value];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitBoundText(ast: BoundTextAst, context: any): any {
|
||||
const res = [BoundTextAst, unparse(ast.value, this.interpolationConfig)];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitText(ast: TextAst, context: any): any {
|
||||
const res = [TextAst, ast.value];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitDirective(ast: DirectiveAst, context: any): any {
|
||||
const res = [DirectiveAst, ast.directive];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
templateVisitAll(this, ast.inputs);
|
||||
templateVisitAll(this, ast.hostProperties);
|
||||
templateVisitAll(this, ast.hostEvents);
|
||||
return null;
|
||||
}
|
||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any {
|
||||
const res = [
|
||||
BoundDirectivePropertyAst, ast.directiveName, unparse(ast.value, this.interpolationConfig)
|
||||
];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
|
||||
private _appendContext(ast: TemplateAst, input: any[]): any[] {
|
||||
if (!this.includeSourceSpan) return input;
|
||||
input.push(ast.sourceSpan !.toString());
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
function humanizeContentProjection(templateAsts: TemplateAst[]): any[] {
|
||||
const humanizer = new TemplateContentProjectionHumanizer();
|
||||
templateVisitAll(humanizer, templateAsts);
|
||||
return humanizer.result;
|
||||
}
|
||||
|
||||
class TemplateContentProjectionHumanizer implements TemplateAstVisitor {
|
||||
result: any[] = [];
|
||||
visitNgContent(ast: NgContentAst, context: any): any {
|
||||
this.result.push(['ng-content', ast.ngContentIndex]);
|
||||
return null;
|
||||
}
|
||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
||||
this.result.push(['template', ast.ngContentIndex]);
|
||||
templateVisitAll(this, ast.children);
|
||||
return null;
|
||||
}
|
||||
visitElement(ast: ElementAst, context: any): any {
|
||||
this.result.push([ast.name, ast.ngContentIndex]);
|
||||
templateVisitAll(this, ast.children);
|
||||
return null;
|
||||
}
|
||||
visitReference(ast: ReferenceAst, context: any): any { return null; }
|
||||
visitVariable(ast: VariableAst, context: any): any { return null; }
|
||||
visitEvent(ast: BoundEventAst, context: any): any { return null; }
|
||||
visitElementProperty(ast: BoundElementPropertyAst, context: any): any { return null; }
|
||||
visitAttr(ast: AttrAst, context: any): any { return null; }
|
||||
visitBoundText(ast: BoundTextAst, context: any): any {
|
||||
this.result.push([`#text(${unparse(ast.value)})`, ast.ngContentIndex]);
|
||||
return null;
|
||||
}
|
||||
visitText(ast: TextAst, context: any): any {
|
||||
this.result.push([`#text(${ast.value})`, ast.ngContentIndex]);
|
||||
return null;
|
||||
}
|
||||
visitDirective(ast: DirectiveAst, context: any): any { return null; }
|
||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any { return null; }
|
||||
}
|
||||
|
||||
class ThrowingVisitor implements TemplateAstVisitor {
|
||||
visitNgContent(ast: NgContentAst, context: any): any { throw 'not implemented'; }
|
||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any { throw 'not implemented'; }
|
||||
visitElement(ast: ElementAst, context: any): any { throw 'not implemented'; }
|
||||
visitReference(ast: ReferenceAst, context: any): any { throw 'not implemented'; }
|
||||
visitVariable(ast: VariableAst, context: any): any { throw 'not implemented'; }
|
||||
visitEvent(ast: BoundEventAst, context: any): any { throw 'not implemented'; }
|
||||
visitElementProperty(ast: BoundElementPropertyAst, context: any): any { throw 'not implemented'; }
|
||||
visitAttr(ast: AttrAst, context: any): any { throw 'not implemented'; }
|
||||
visitBoundText(ast: BoundTextAst, context: any): any { throw 'not implemented'; }
|
||||
visitText(ast: TextAst, context: any): any { throw 'not implemented'; }
|
||||
visitDirective(ast: DirectiveAst, context: any): any { throw 'not implemented'; }
|
||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any {
|
||||
throw 'not implemented';
|
||||
}
|
||||
}
|
||||
|
||||
class FooAstTransformer extends ThrowingVisitor {
|
||||
visitElement(ast: ElementAst, context: any): any {
|
||||
if (ast.name != 'div') return ast;
|
||||
return new ElementAst(
|
||||
'foo', [], [], [], [], [], [], false, [], [], ast.ngContentIndex, ast.sourceSpan,
|
||||
ast.endSourceSpan);
|
||||
}
|
||||
}
|
||||
|
||||
class BarAstTransformer extends FooAstTransformer {
|
||||
visitElement(ast: ElementAst, context: any): any {
|
||||
if (ast.name != 'foo') return ast;
|
||||
return new ElementAst(
|
||||
'bar', [], [], [], [], [], [], false, [], [], ast.ngContentIndex, ast.sourceSpan,
|
||||
ast.endSourceSpan);
|
||||
}
|
||||
}
|
||||
|
||||
class NullVisitor implements TemplateAstVisitor {
|
||||
visitNgContent(ast: NgContentAst, context: any): any {}
|
||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {}
|
||||
visitElement(ast: ElementAst, context: any): any {}
|
||||
visitReference(ast: ReferenceAst, context: any): any {}
|
||||
visitVariable(ast: VariableAst, context: any): any {}
|
||||
visitEvent(ast: BoundEventAst, context: any): any {}
|
||||
visitElementProperty(ast: BoundElementPropertyAst, context: any): any {}
|
||||
visitAttr(ast: AttrAst, context: any): any {}
|
||||
visitBoundText(ast: BoundTextAst, context: any): any {}
|
||||
visitText(ast: TextAst, context: any): any {}
|
||||
visitDirective(ast: DirectiveAst, context: any): any {}
|
||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any {}
|
||||
}
|
||||
|
||||
class ArrayConsole implements Console {
|
||||
logs: string[] = [];
|
||||
warnings: string[] = [];
|
||||
log(msg: string) { this.logs.push(msg); }
|
||||
warn(msg: string) { this.warnings.push(msg); }
|
||||
}
|
||||
|
||||
|
||||
(function(){
|
||||
let ngIf: CompileDirectiveSummary;
|
||||
let parse: (
|
||||
template: string, directives: CompileDirectiveSummary[], pipes?: CompilePipeSummary[],
|
||||
@ -2179,210 +2385,4 @@ The pipe 'test' could not be found ("{{[ERROR ->]a | test}}"): TestComp@0:2`);
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function humanizeTplAst(
|
||||
templateAsts: TemplateAst[], interpolationConfig?: InterpolationConfig): any[] {
|
||||
const humanizer = new TemplateHumanizer(false, interpolationConfig);
|
||||
templateVisitAll(humanizer, templateAsts);
|
||||
return humanizer.result;
|
||||
}
|
||||
|
||||
function humanizeTplAstSourceSpans(
|
||||
templateAsts: TemplateAst[], interpolationConfig?: InterpolationConfig): any[] {
|
||||
const humanizer = new TemplateHumanizer(true, interpolationConfig);
|
||||
templateVisitAll(humanizer, templateAsts);
|
||||
return humanizer.result;
|
||||
}
|
||||
|
||||
class TemplateHumanizer implements TemplateAstVisitor {
|
||||
result: any[] = [];
|
||||
|
||||
constructor(
|
||||
private includeSourceSpan: boolean,
|
||||
private interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG) {}
|
||||
|
||||
visitNgContent(ast: NgContentAst, context: any): any {
|
||||
const res = [NgContentAst];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
||||
const res = [EmbeddedTemplateAst];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
templateVisitAll(this, ast.attrs);
|
||||
templateVisitAll(this, ast.outputs);
|
||||
templateVisitAll(this, ast.references);
|
||||
templateVisitAll(this, ast.variables);
|
||||
templateVisitAll(this, ast.directives);
|
||||
templateVisitAll(this, ast.children);
|
||||
return null;
|
||||
}
|
||||
visitElement(ast: ElementAst, context: any): any {
|
||||
const res = [ElementAst, ast.name];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
templateVisitAll(this, ast.attrs);
|
||||
templateVisitAll(this, ast.inputs);
|
||||
templateVisitAll(this, ast.outputs);
|
||||
templateVisitAll(this, ast.references);
|
||||
templateVisitAll(this, ast.directives);
|
||||
templateVisitAll(this, ast.children);
|
||||
return null;
|
||||
}
|
||||
visitReference(ast: ReferenceAst, context: any): any {
|
||||
const res = [ReferenceAst, ast.name, ast.value];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitVariable(ast: VariableAst, context: any): any {
|
||||
const res = [VariableAst, ast.name, ast.value];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitEvent(ast: BoundEventAst, context: any): any {
|
||||
const res =
|
||||
[BoundEventAst, ast.name, ast.target, unparse(ast.handler, this.interpolationConfig)];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitElementProperty(ast: BoundElementPropertyAst, context: any): any {
|
||||
const res = [
|
||||
BoundElementPropertyAst, ast.type, ast.name, unparse(ast.value, this.interpolationConfig),
|
||||
ast.unit
|
||||
];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitAttr(ast: AttrAst, context: any): any {
|
||||
const res = [AttrAst, ast.name, ast.value];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitBoundText(ast: BoundTextAst, context: any): any {
|
||||
const res = [BoundTextAst, unparse(ast.value, this.interpolationConfig)];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitText(ast: TextAst, context: any): any {
|
||||
const res = [TextAst, ast.value];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
visitDirective(ast: DirectiveAst, context: any): any {
|
||||
const res = [DirectiveAst, ast.directive];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
templateVisitAll(this, ast.inputs);
|
||||
templateVisitAll(this, ast.hostProperties);
|
||||
templateVisitAll(this, ast.hostEvents);
|
||||
return null;
|
||||
}
|
||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any {
|
||||
const res = [
|
||||
BoundDirectivePropertyAst, ast.directiveName, unparse(ast.value, this.interpolationConfig)
|
||||
];
|
||||
this.result.push(this._appendContext(ast, res));
|
||||
return null;
|
||||
}
|
||||
|
||||
private _appendContext(ast: TemplateAst, input: any[]): any[] {
|
||||
if (!this.includeSourceSpan) return input;
|
||||
input.push(ast.sourceSpan !.toString());
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
function humanizeContentProjection(templateAsts: TemplateAst[]): any[] {
|
||||
const humanizer = new TemplateContentProjectionHumanizer();
|
||||
templateVisitAll(humanizer, templateAsts);
|
||||
return humanizer.result;
|
||||
}
|
||||
|
||||
class TemplateContentProjectionHumanizer implements TemplateAstVisitor {
|
||||
result: any[] = [];
|
||||
visitNgContent(ast: NgContentAst, context: any): any {
|
||||
this.result.push(['ng-content', ast.ngContentIndex]);
|
||||
return null;
|
||||
}
|
||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {
|
||||
this.result.push(['template', ast.ngContentIndex]);
|
||||
templateVisitAll(this, ast.children);
|
||||
return null;
|
||||
}
|
||||
visitElement(ast: ElementAst, context: any): any {
|
||||
this.result.push([ast.name, ast.ngContentIndex]);
|
||||
templateVisitAll(this, ast.children);
|
||||
return null;
|
||||
}
|
||||
visitReference(ast: ReferenceAst, context: any): any { return null; }
|
||||
visitVariable(ast: VariableAst, context: any): any { return null; }
|
||||
visitEvent(ast: BoundEventAst, context: any): any { return null; }
|
||||
visitElementProperty(ast: BoundElementPropertyAst, context: any): any { return null; }
|
||||
visitAttr(ast: AttrAst, context: any): any { return null; }
|
||||
visitBoundText(ast: BoundTextAst, context: any): any {
|
||||
this.result.push([`#text(${unparse(ast.value)})`, ast.ngContentIndex]);
|
||||
return null;
|
||||
}
|
||||
visitText(ast: TextAst, context: any): any {
|
||||
this.result.push([`#text(${ast.value})`, ast.ngContentIndex]);
|
||||
return null;
|
||||
}
|
||||
visitDirective(ast: DirectiveAst, context: any): any { return null; }
|
||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any { return null; }
|
||||
}
|
||||
|
||||
class ThrowingVisitor implements TemplateAstVisitor {
|
||||
visitNgContent(ast: NgContentAst, context: any): any { throw 'not implemented'; }
|
||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any { throw 'not implemented'; }
|
||||
visitElement(ast: ElementAst, context: any): any { throw 'not implemented'; }
|
||||
visitReference(ast: ReferenceAst, context: any): any { throw 'not implemented'; }
|
||||
visitVariable(ast: VariableAst, context: any): any { throw 'not implemented'; }
|
||||
visitEvent(ast: BoundEventAst, context: any): any { throw 'not implemented'; }
|
||||
visitElementProperty(ast: BoundElementPropertyAst, context: any): any { throw 'not implemented'; }
|
||||
visitAttr(ast: AttrAst, context: any): any { throw 'not implemented'; }
|
||||
visitBoundText(ast: BoundTextAst, context: any): any { throw 'not implemented'; }
|
||||
visitText(ast: TextAst, context: any): any { throw 'not implemented'; }
|
||||
visitDirective(ast: DirectiveAst, context: any): any { throw 'not implemented'; }
|
||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any {
|
||||
throw 'not implemented';
|
||||
}
|
||||
}
|
||||
|
||||
class FooAstTransformer extends ThrowingVisitor {
|
||||
visitElement(ast: ElementAst, context: any): any {
|
||||
if (ast.name != 'div') return ast;
|
||||
return new ElementAst(
|
||||
'foo', [], [], [], [], [], [], false, [], [], ast.ngContentIndex, ast.sourceSpan,
|
||||
ast.endSourceSpan);
|
||||
}
|
||||
}
|
||||
|
||||
class BarAstTransformer extends FooAstTransformer {
|
||||
visitElement(ast: ElementAst, context: any): any {
|
||||
if (ast.name != 'foo') return ast;
|
||||
return new ElementAst(
|
||||
'bar', [], [], [], [], [], [], false, [], [], ast.ngContentIndex, ast.sourceSpan,
|
||||
ast.endSourceSpan);
|
||||
}
|
||||
}
|
||||
|
||||
class NullVisitor implements TemplateAstVisitor {
|
||||
visitNgContent(ast: NgContentAst, context: any): any {}
|
||||
visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any {}
|
||||
visitElement(ast: ElementAst, context: any): any {}
|
||||
visitReference(ast: ReferenceAst, context: any): any {}
|
||||
visitVariable(ast: VariableAst, context: any): any {}
|
||||
visitEvent(ast: BoundEventAst, context: any): any {}
|
||||
visitElementProperty(ast: BoundElementPropertyAst, context: any): any {}
|
||||
visitAttr(ast: AttrAst, context: any): any {}
|
||||
visitBoundText(ast: BoundTextAst, context: any): any {}
|
||||
visitText(ast: TextAst, context: any): any {}
|
||||
visitDirective(ast: DirectiveAst, context: any): any {}
|
||||
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any {}
|
||||
}
|
||||
|
||||
class ArrayConsole implements Console {
|
||||
logs: string[] = [];
|
||||
warnings: string[] = [];
|
||||
log(msg: string) { this.logs.push(msg); }
|
||||
warn(msg: string) { this.warnings.push(msg); }
|
||||
}
|
||||
})();
|
||||
|
@ -11,7 +11,7 @@ import {Element} from '../../src/ml_parser/ast';
|
||||
import {HtmlParser} from '../../src/ml_parser/html_parser';
|
||||
import {PreparsedElement, PreparsedElementType, preparseElement} from '../../src/template_parser/template_preparser';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('preparseElement', () => {
|
||||
let htmlParser: HtmlParser;
|
||||
beforeEach(inject([HtmlParser], (_htmlParser: HtmlParser) => { htmlParser = _htmlParser; }));
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {UrlResolver, createOfflineCompileUrlResolver} from '@angular/compiler/src/url_resolver';
|
||||
import {beforeEach, describe, expect, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('UrlResolver', () => {
|
||||
let resolver = new UrlResolver();
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {fakeAsync} from '@angular/core/testing/src/fake_async';
|
||||
import {SyncAsync, escapeRegExp, splitAtColon, utf8Encode} from '../src/util';
|
||||
|
||||
export function main() {
|
||||
{
|
||||
describe('util', () => {
|
||||
describe('splitAtColon', () => {
|
||||
it('should split when a single ":" is present', () => {
|
||||
|
Reference in New Issue
Block a user