build: reformat repo to new clang@1.4.0 (#36613)

PR Close #36613
This commit is contained in:
Joey Perrott
2020-04-13 16:40:21 -07:00
committed by atscott
parent 5e80e7e216
commit 698b0288be
1160 changed files with 31667 additions and 24000 deletions

View File

@ -15,7 +15,6 @@ import {SpyChangeDetectorRef} from '../spies';
{
describe('AsyncPipe', () => {
describe('Observable', () => {
let emitter: EventEmitter<any>;
let pipe: AsyncPipe;
@ -29,8 +28,9 @@ import {SpyChangeDetectorRef} from '../spies';
});
describe('transform', () => {
it('should return null when subscribing to an observable',
() => { expect(pipe.transform(emitter)).toBe(null); });
it('should return null when subscribing to an observable', () => {
expect(pipe.transform(emitter)).toBe(null);
});
it('should return the latest available value wrapped',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
@ -96,8 +96,9 @@ import {SpyChangeDetectorRef} from '../spies';
});
describe('ngOnDestroy', () => {
it('should do nothing when no subscription',
() => { expect(() => pipe.ngOnDestroy()).not.toThrow(); });
it('should do nothing when no subscription', () => {
expect(() => pipe.ngOnDestroy()).not.toThrow();
});
it('should dispose of the existing subscription',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
@ -133,8 +134,9 @@ import {SpyChangeDetectorRef} from '../spies';
});
describe('transform', () => {
it('should return null when subscribing to a promise',
() => { expect(pipe.transform(promise)).toBe(null); });
it('should return null when subscribing to a promise', () => {
expect(pipe.transform(promise)).toBe(null);
});
it('should return the latest available value',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
@ -189,8 +191,9 @@ import {SpyChangeDetectorRef} from '../spies';
}));
describe('ngOnDestroy', () => {
it('should do nothing when no source',
() => { expect(() => pipe.ngOnDestroy()).not.toThrow(); });
it('should do nothing when no source', () => {
expect(() => pipe.ngOnDestroy()).not.toThrow();
});
it('should dispose of the existing source',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {

View File

@ -12,41 +12,55 @@ import {LowerCasePipe, TitleCasePipe, UpperCasePipe} from '@angular/common';
describe('LowerCasePipe', () => {
let pipe: LowerCasePipe;
beforeEach(() => { pipe = new LowerCasePipe(); });
beforeEach(() => {
pipe = new LowerCasePipe();
});
it('should return lowercase', () => { expect(pipe.transform('FOO')).toEqual('foo'); });
it('should return lowercase', () => {
expect(pipe.transform('FOO')).toEqual('foo');
});
it('should lowercase when there is a new value', () => {
expect(pipe.transform('FOO')).toEqual('foo');
expect(pipe.transform('BAr')).toEqual('bar');
});
it('should not support other objects',
() => { expect(() => pipe.transform(<any>{})).toThrowError(); });
it('should not support other objects', () => {
expect(() => pipe.transform(<any>{})).toThrowError();
});
});
describe('TitleCasePipe', () => {
let pipe: TitleCasePipe;
beforeEach(() => { pipe = new TitleCasePipe(); });
beforeEach(() => {
pipe = new TitleCasePipe();
});
it('should return titlecase', () => { expect(pipe.transform('foo')).toEqual('Foo'); });
it('should return titlecase', () => {
expect(pipe.transform('foo')).toEqual('Foo');
});
it('should return titlecase for subsequent words',
() => { expect(pipe.transform('one TWO Three fouR')).toEqual('One Two Three Four'); });
it('should return titlecase for subsequent words', () => {
expect(pipe.transform('one TWO Three fouR')).toEqual('One Two Three Four');
});
it('should support empty strings', () => { expect(pipe.transform('')).toEqual(''); });
it('should support empty strings', () => {
expect(pipe.transform('')).toEqual('');
});
it('should persist whitespace',
() => { expect(pipe.transform('one two')).toEqual('One Two'); });
it('should persist whitespace', () => {
expect(pipe.transform('one two')).toEqual('One Two');
});
it('should titlecase when there is a new value', () => {
expect(pipe.transform('bar')).toEqual('Bar');
expect(pipe.transform('foo')).toEqual('Foo');
});
it('should not capitalize letter after the quotes',
() => { expect(pipe.transform('it\'s complicated')).toEqual('It\'s Complicated'); });
it('should not capitalize letter after the quotes', () => {
expect(pipe.transform('it\'s complicated')).toEqual('It\'s Complicated');
});
it('should not treat non-space character as a separator', () => {
expect(pipe.transform('one,two,three')).toEqual('One,two,three');
@ -66,23 +80,29 @@ import {LowerCasePipe, TitleCasePipe, UpperCasePipe} from '@angular/common';
expect(pipe.transform('éric')).toEqual('Éric');
});
it('should not support other objects',
() => { expect(() => pipe.transform(<any>{})).toThrowError(); });
it('should not support other objects', () => {
expect(() => pipe.transform(<any>{})).toThrowError();
});
});
describe('UpperCasePipe', () => {
let pipe: UpperCasePipe;
beforeEach(() => { pipe = new UpperCasePipe(); });
beforeEach(() => {
pipe = new UpperCasePipe();
});
it('should return uppercase', () => { expect(pipe.transform('foo')).toEqual('FOO'); });
it('should return uppercase', () => {
expect(pipe.transform('foo')).toEqual('FOO');
});
it('should uppercase when there is a new value', () => {
expect(pipe.transform('foo')).toEqual('FOO');
expect(pipe.transform('bar')).toEqual('BAR');
});
it('should not support other objects',
() => { expect(() => pipe.transform(<any>{})).toThrowError(); });
it('should not support other objects', () => {
expect(() => pipe.transform(<any>{})).toThrowError();
});
});
}

View File

@ -10,8 +10,8 @@ import {DatePipe} from '@angular/common';
import localeEn from '@angular/common/locales/en';
import localeEnExtra from '@angular/common/locales/extra/en';
import {PipeResolver} from '@angular/compiler/src/pipe_resolver';
import {ɵregisterLocaleData, ɵunregisterLocaleData} from '@angular/core';
import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_reflector';
import {ɵunregisterLocaleData, ɵregisterLocaleData} from '@angular/core';
{
let date: Date;
@ -28,33 +28,44 @@ import {ɵunregisterLocaleData, ɵregisterLocaleData} from '@angular/core';
});
it('should be marked as pure', () => {
expect(new PipeResolver(new JitReflector()).resolve(DatePipe) !.pure).toEqual(true);
expect(new PipeResolver(new JitReflector()).resolve(DatePipe)!.pure).toEqual(true);
});
describe('supports', () => {
it('should support date', () => { expect(() => pipe.transform(date)).not.toThrow(); });
it('should support date', () => {
expect(() => pipe.transform(date)).not.toThrow();
});
it('should support int', () => { expect(() => pipe.transform(123456789)).not.toThrow(); });
it('should support int', () => {
expect(() => pipe.transform(123456789)).not.toThrow();
});
it('should support numeric strings',
() => { expect(() => pipe.transform('123456789')).not.toThrow(); });
it('should support numeric strings', () => {
expect(() => pipe.transform('123456789')).not.toThrow();
});
it('should support decimal strings',
() => { expect(() => pipe.transform('123456789.11')).not.toThrow(); });
it('should support decimal strings', () => {
expect(() => pipe.transform('123456789.11')).not.toThrow();
});
it('should support ISO string',
() => expect(() => pipe.transform('2015-06-15T21:43:11Z')).not.toThrow());
it('should return null for empty string',
() => { expect(pipe.transform('')).toEqual(null); });
it('should return null for empty string', () => {
expect(pipe.transform('')).toEqual(null);
});
it('should return null for NaN', () => { expect(pipe.transform(Number.NaN)).toEqual(null); });
it('should return null for NaN', () => {
expect(pipe.transform(Number.NaN)).toEqual(null);
});
it('should support ISO string without time',
() => { expect(() => pipe.transform(isoStringWithoutTime)).not.toThrow(); });
it('should support ISO string without time', () => {
expect(() => pipe.transform(isoStringWithoutTime)).not.toThrow();
});
it('should not support other objects',
() => { expect(() => pipe.transform({})).toThrowError(/InvalidPipeArgument/); });
it('should not support other objects', () => {
expect(() => pipe.transform({})).toThrowError(/InvalidPipeArgument/);
});
});
describe('transform', () => {

View File

@ -29,7 +29,7 @@ import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_refle
});
it('should be marked as pure', () => {
expect(new PipeResolver(new JitReflector()).resolve(I18nPluralPipe) !.pure).toEqual(true);
expect(new PipeResolver(new JitReflector()).resolve(I18nPluralPipe)!.pure).toEqual(true);
});
describe('transform', () => {
@ -54,17 +54,19 @@ import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_refle
});
it('should use "" if value is undefined', () => {
const val = pipe.transform(void(0) as any, mapping);
const val = pipe.transform(void (0) as any, mapping);
expect(val).toEqual('');
});
it('should not support bad arguments',
() => { expect(() => pipe.transform(0, <any>'hey')).toThrowError(); });
it('should not support bad arguments', () => {
expect(() => pipe.transform(0, <any>'hey')).toThrowError();
});
});
});
}
class TestLocalization extends NgLocalization {
getPluralCategory(value: number): string { return value > 1 && value < 6 ? 'many' : 'other'; }
getPluralCategory(value: number): string {
return value > 1 && value < 6 ? 'many' : 'other';
}
}

View File

@ -16,7 +16,7 @@ import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_refle
const mapping = {'male': 'Invite him.', 'female': 'Invite her.', 'other': 'Invite them.'};
it('should be marked as pure', () => {
expect(new PipeResolver(new JitReflector()).resolve(I18nSelectPipe) !.pure).toEqual(true);
expect(new PipeResolver(new JitReflector()).resolve(I18nSelectPipe)!.pure).toEqual(true);
});
describe('transform', () => {
@ -30,17 +30,18 @@ import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_refle
expect(val).toEqual('Invite her.');
});
it('should return the "other" text if value is neither "male" nor "female"',
() => { expect(pipe.transform('Anything else', mapping)).toEqual('Invite them.'); });
it('should return the "other" text if value is neither "male" nor "female"', () => {
expect(pipe.transform('Anything else', mapping)).toEqual('Invite them.');
});
it('should return an empty text if value is null or undefined', () => {
expect(pipe.transform(null, mapping)).toEqual('');
expect(pipe.transform(void 0, mapping)).toEqual('');
});
it('should throw on bad arguments',
() => { expect(() => pipe.transform('male', <any>'hey')).toThrowError(); });
it('should throw on bad arguments', () => {
expect(() => pipe.transform('male', <any>'hey')).toThrowError();
});
});
});
}

View File

@ -8,7 +8,7 @@
import {CommonModule, JsonPipe} from '@angular/common';
import {Component} from '@angular/core';
import {TestBed, async} from '@angular/core/testing';
import {async, TestBed} from '@angular/core/testing';
import {expect} from '@angular/platform-browser/testing/src/matchers';
{
@ -18,7 +18,9 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
let inceptionObjString: string;
let pipe: JsonPipe;
function normalize(obj: string): string { return obj.replace(regNewLine, ''); }
function normalize(obj: string): string {
return obj.replace(regNewLine, '');
}
beforeEach(() => {
inceptionObj = {dream: {dream: {dream: 'Limbo'}}};
@ -35,8 +37,9 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
});
describe('transform', () => {
it('should return JSON-formatted string',
() => { expect(pipe.transform(inceptionObj)).toEqual(inceptionObjString); });
it('should return JSON-formatted string', () => {
expect(pipe.transform(inceptionObj)).toEqual(inceptionObjString);
});
it('should return JSON-formatted string even when normalized', () => {
const dream1 = normalize(pipe.transform(inceptionObj));
@ -52,7 +55,6 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
});
describe('integration', () => {
@Component({selector: 'test-comp', template: '{{data | json}}'})
class TestComp {
data: any;

View File

@ -64,12 +64,12 @@ describe('KeyValuePipe', () => {
expect(transform1 !== transform2).toEqual(true);
});
it('should accept a type union of an object with string keys and null', () => {
let value !: {[key: string]: string} | null;
let value!: {[key: string]: string}|null;
const pipe = new KeyValuePipe(defaultKeyValueDiffers);
expect(pipe.transform(value)).toEqual(null);
});
it('should accept a type union of an object with number keys and null', () => {
let value !: {[key: number]: string} | null;
let value!: {[key: number]: string}|null;
const pipe = new KeyValuePipe(defaultKeyValueDiffers);
expect(pipe.transform(value)).toEqual(null);
});
@ -126,7 +126,7 @@ describe('KeyValuePipe', () => {
expect(transform1 !== transform2).toEqual(true);
});
it('should accept a type union of a Map and null', () => {
let value !: Map<number, number>| null;
let value!: Map<number, number>|null;
const pipe = new KeyValuePipe(defaultKeyValueDiffers);
expect(pipe.transform(value)).toEqual(null);
});

View File

@ -6,14 +6,14 @@
* found in the LICENSE file at https://angular.io/license
*/
import {CurrencyPipe, DecimalPipe, PercentPipe} from '@angular/common';
import localeAr from '@angular/common/locales/ar';
import localeDa from '@angular/common/locales/da';
import localeDeAt from '@angular/common/locales/de-AT';
import localeEn from '@angular/common/locales/en';
import localeEsUS from '@angular/common/locales/es-US';
import localeFr from '@angular/common/locales/fr';
import localeAr from '@angular/common/locales/ar';
import localeDeAt from '@angular/common/locales/de-AT';
import localeDa from '@angular/common/locales/da';
import {ɵunregisterLocaleData, ɵregisterLocaleData} from '@angular/core';
import {CurrencyPipe, DecimalPipe, PercentPipe} from '@angular/common';
import {ɵregisterLocaleData, ɵunregisterLocaleData} from '@angular/core';
import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testing_internal';
{
@ -32,7 +32,9 @@ import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testin
describe('DecimalPipe', () => {
describe('transform', () => {
let pipe: DecimalPipe;
beforeEach(() => { pipe = new DecimalPipe('en-US'); });
beforeEach(() => {
pipe = new DecimalPipe('en-US');
});
it('should return correct value for numbers', () => {
expect(pipe.transform(12345)).toEqual('12,345');
@ -68,7 +70,9 @@ import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testin
describe('PercentPipe', () => {
let pipe: PercentPipe;
beforeEach(() => { pipe = new PercentPipe('en-US'); });
beforeEach(() => {
pipe = new PercentPipe('en-US');
});
describe('transform', () => {
it('should return correct value for numbers', () => {
@ -89,7 +93,9 @@ import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testin
describe('CurrencyPipe', () => {
let pipe: CurrencyPipe;
beforeEach(() => { pipe = new CurrencyPipe('en-US', 'USD'); });
beforeEach(() => {
pipe = new CurrencyPipe('en-US', 'USD');
});
describe('transform', () => {
it('should return correct value for numbers', () => {

View File

@ -8,7 +8,7 @@
import {CommonModule, SlicePipe} from '@angular/common';
import {Component} from '@angular/core';
import {TestBed, async} from '@angular/core/testing';
import {async, TestBed} from '@angular/core/testing';
import {expect} from '@angular/platform-browser/testing/src/matchers';
{
@ -24,24 +24,32 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
});
describe('supports', () => {
it('should support strings', () => { expect(() => pipe.transform(str, 0)).not.toThrow(); });
it('should support lists', () => { expect(() => pipe.transform(list, 0)).not.toThrow(); });
it('should support readonly lists',
() => { expect(() => pipe.transform(list as ReadonlyArray<number>, 0)).not.toThrow(); });
it('should support strings', () => {
expect(() => pipe.transform(str, 0)).not.toThrow();
});
it('should support lists', () => {
expect(() => pipe.transform(list, 0)).not.toThrow();
});
it('should support readonly lists', () => {
expect(() => pipe.transform(list as ReadonlyArray<number>, 0)).not.toThrow();
});
it('should not support other objects',
// this would not compile
// so we cast as `any` to check that it throws for unsupported objects
() => { expect(() => pipe.transform({} as any, 0)).toThrow(); });
() => {
expect(() => pipe.transform({} as any, 0)).toThrow();
});
});
describe('transform', () => {
it('should return null if the value is null', () => {
expect(pipe.transform(null, 1)).toBe(null);
});
it('should return null if the value is null',
() => { expect(pipe.transform(null, 1)).toBe(null); });
it('should return undefined if the value is undefined',
() => { expect(pipe.transform(undefined, 1)).toBe(undefined); });
it('should return undefined if the value is undefined', () => {
expect(pipe.transform(undefined, 1)).toBe(undefined);
});
it('should return all items after START index when START is positive and END is omitted',
() => {
@ -85,11 +93,9 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
expect(pipe.transform(list, 2)).toEqual([3, 4, 5]);
expect(list).toEqual([1, 2, 3, 4, 5]);
});
});
describe('integration', () => {
@Component({selector: 'test-comp', template: '{{(data | slice:1).join(",") }}'})
class TestComp {
data: any;