fix(ivy): assertLessThan asserts the wrong thing (#21430)
assertLessThan() actually does the opposite of what it advertises. It's only through luck that existing asserts have not failed before. This changes assertLessThan to actually assert that the value is less than something. PR Close #21430
This commit is contained in:
parent
95fbb7d675
commit
c5586b7dfa
|
@ -37,7 +37,7 @@ export function assertEqual<T>(
|
|||
}
|
||||
|
||||
export function assertLessThan<T>(actual: T, expected: T, name: string) {
|
||||
(actual < expected) && assertThrow(actual, expected, name, '>');
|
||||
(actual >= expected) && assertThrow(actual, expected, name, '<');
|
||||
}
|
||||
|
||||
export function assertNotNull<T>(actual: T, name: string) {
|
||||
|
|
|
@ -1878,8 +1878,8 @@ export function memory<T>(index: number, value?: T): T {
|
|||
}
|
||||
|
||||
function valueInData<T>(data: any[], index: number, value?: T): T {
|
||||
ngDevMode && assertDataInRange(index, data);
|
||||
if (value === undefined) {
|
||||
ngDevMode && assertDataInRange(index, data);
|
||||
value = data[index];
|
||||
} else {
|
||||
// We don't store any static data for local variables, so the first time
|
||||
|
@ -1914,5 +1914,5 @@ function assertHasParent() {
|
|||
|
||||
function assertDataInRange(index: number, arr?: any[]) {
|
||||
if (arr == null) arr = data;
|
||||
assertLessThan(arr ? arr.length : 0, index, 'data.length');
|
||||
assertLessThan(index, arr ? arr.length : 0, 'data.length');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue