diff --git a/front_end/issues/IssueSurveyLink.ts b/front_end/issues/IssueSurveyLink.ts index 925f1f4bbe..17b970951c 100644 --- a/front_end/issues/IssueSurveyLink.ts +++ b/front_end/issues/IssueSurveyLink.ts @@ -18,7 +18,7 @@ export interface IssueSurveyLinkData { showSurvey: (trigger: string, callback: ShowSurveyCallback) => void; } -enum State { +const enum State { Checking = 'Checking', // (begin state) -> ShowLink | DontShowLink ShowLink = 'ShowLink', // -> Sending Sending = 'Sending', // -> SurveyShown | Failed diff --git a/front_end/linear_memory_inspector/BUILD.gn b/front_end/linear_memory_inspector/BUILD.gn index 1d23c49c0a..ff6c97f7bb 100644 --- a/front_end/linear_memory_inspector/BUILD.gn +++ b/front_end/linear_memory_inspector/BUILD.gn @@ -25,10 +25,7 @@ devtools_module("linear_memory_inspector") { "../third_party/lit-html:bundle", ] - visibility = [ - "../../test/unittests/front_end/linear_memory_inspector", - "../component_docs/*", - ] + visibility = [ "../component_docs/*" ] } devtools_entrypoint("bundle") { diff --git a/front_end/linear_memory_inspector/ValueInterpreterDisplayUtils.ts b/front_end/linear_memory_inspector/ValueInterpreterDisplayUtils.ts index 10331987b2..44696c0936 100644 --- a/front_end/linear_memory_inspector/ValueInterpreterDisplayUtils.ts +++ b/front_end/linear_memory_inspector/ValueInterpreterDisplayUtils.ts @@ -4,7 +4,7 @@ export const VALUE_INTEPRETER_MAX_NUM_BYTES = 8; -export enum ValueType { +export const enum ValueType { Int8 = 'Integer 8-bit', Int16 = 'Integer 16-bit', Int32 = 'Integer 32-bit', @@ -14,12 +14,12 @@ export enum ValueType { String = 'String' } -export enum Endianness { +export const enum Endianness { Little = 'Little Endian', Big = 'Big Endian' } -export enum ValueTypeMode { +export const enum ValueTypeMode { Decimal = 'dec', Hexadecimal = 'hex', Octal = 'oct', diff --git a/front_end/linear_memory_inspector/ValueInterpreterSettings.ts b/front_end/linear_memory_inspector/ValueInterpreterSettings.ts index 209307a120..57d43032d5 100644 --- a/front_end/linear_memory_inspector/ValueInterpreterSettings.ts +++ b/front_end/linear_memory_inspector/ValueInterpreterSettings.ts @@ -14,7 +14,7 @@ export interface ValueInterpreterSettingsData { valueTypes: Set; } -enum ValueTypeGroup { +const enum ValueTypeGroup { Integer = 'Integer', Float = 'Floating point', Other = 'Other' diff --git a/inspector_overlay/highlight_common.ts b/inspector_overlay/highlight_common.ts index be021cda25..08aade030b 100644 --- a/inspector_overlay/highlight_common.ts +++ b/inspector_overlay/highlight_common.ts @@ -47,7 +47,7 @@ export interface BoxStyle { hatchColor?: string; } -enum LinePattern { +const enum LinePattern { Solid = 'solid', Dotted = 'dotted', Dashed = 'dashed' diff --git a/test/shared/text-color.ts b/test/shared/text-color.ts index bebe48cf6b..5237cce319 100644 --- a/test/shared/text-color.ts +++ b/test/shared/text-color.ts @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -export enum TextColor { +export const enum TextColor { DIM = 'DIM', GREEN = 'GREEN', RED = 'RED', diff --git a/test/unittests/front_end/helpers/MutationHelpers.ts b/test/unittests/front_end/helpers/MutationHelpers.ts index 807cef796f..45568cc4bb 100644 --- a/test/unittests/front_end/helpers/MutationHelpers.ts +++ b/test/unittests/front_end/helpers/MutationHelpers.ts @@ -4,7 +4,7 @@ const {assert} = chai; -export enum MutationType { +export const enum MutationType { ADD = 'ADD', REMOVE = 'REMOVE', TEXT_UPDATE = 'TEXT_UPDATE', diff --git a/test/unittests/front_end/linear_memory_inspector/LinearMemoryValueInterpreter_test.ts b/test/unittests/front_end/linear_memory_inspector/LinearMemoryValueInterpreter_test.ts index f4997c59b8..d02ee1a759 100644 --- a/test/unittests/front_end/linear_memory_inspector/LinearMemoryValueInterpreter_test.ts +++ b/test/unittests/front_end/linear_memory_inspector/LinearMemoryValueInterpreter_test.ts @@ -42,7 +42,7 @@ describe('LinearMemoryValueInterpreter', () => { return component; } - it('renders settings toolbar', async () => { + it('renders the settings toolbar', async () => { const component = setUpComponent(); const settingsToolbar = getElementWithinComponent(component, TOOLBAR_SELECTOR, HTMLDivElement); assert.isNotNull(settingsToolbar); diff --git a/test/unittests/front_end/linear_memory_inspector/ValueInterpreterDisplay_test.ts b/test/unittests/front_end/linear_memory_inspector/ValueInterpreterDisplay_test.ts index 9e9f477623..a19e298569 100644 --- a/test/unittests/front_end/linear_memory_inspector/ValueInterpreterDisplay_test.ts +++ b/test/unittests/front_end/linear_memory_inspector/ValueInterpreterDisplay_test.ts @@ -64,7 +64,7 @@ describe('ValueInterpreterDisplay', () => { } } - it('correctly LinearMemoryInspector.ValueInterpreterDisplayUtils.formats signed/unsigned and endianness for Integer 8-bit (decimal)', + it('correctly formats signed/unsigned and endianness for Integer 8-bit (decimal)', async () => { const formatData = { buffer: new ArrayBuffer(1), @@ -74,7 +74,7 @@ describe('ValueInterpreterDisplay', () => { testNumberFormatCombinations(formatData, combinationsForNumbers); }); - it('correctly LinearMemoryInspector.ValueInterpreterDisplayUtils.formats signed/unsigned and endianness for Integer 16-bit (decimal)', + it('correctly formats signed/unsigned and endianness for Integer 16-bit (decimal)', async () => { const formatData = { buffer: new ArrayBuffer(2), @@ -85,7 +85,7 @@ describe('ValueInterpreterDisplay', () => { testNumberFormatCombinations(formatData, combinationsForNumbers); }); - it('correctly LinearMemoryInspector.ValueInterpreterDisplayUtils.formats signed/unsigned and endianness for Integer 32-bit (decimal)', + it('correctly formats signed/unsigned and endianness for Integer 32-bit (decimal)', async () => { const formatData = { buffer: new ArrayBuffer(4), @@ -96,7 +96,7 @@ describe('ValueInterpreterDisplay', () => { testNumberFormatCombinations(formatData, combinationsForNumbers); }); - it('correctly LinearMemoryInspector.ValueInterpreterDisplayUtils.formats signed/unsigned and endianness for Integer 64-bit (decimal)', + it('correctly formats signed/unsigned and endianness for Integer 64-bit (decimal)', async () => { const formatData = { buffer: new ArrayBuffer(8), @@ -107,7 +107,7 @@ describe('ValueInterpreterDisplay', () => { testNumberFormatCombinations(formatData, combinationsForNumbers); }); - it('correctly LinearMemoryInspector.ValueInterpreterDisplayUtils.formats endianness for Float 32-bit (decimal)', + it('correctly formats endianness for Float 32-bit (decimal)', async () => { const formatData = { buffer: new ArrayBuffer(4), @@ -118,7 +118,7 @@ describe('ValueInterpreterDisplay', () => { testNumberFormatCombinations(formatData, combinationsForNumbers); }); - it('correctly LinearMemoryInspector.ValueInterpreterDisplayUtils.formats endianness for Float 64-bit (decimal)', + it('correctly formats endianness for Float 64-bit (decimal)', async () => { const formatData = { buffer: new ArrayBuffer(8), @@ -129,42 +129,42 @@ describe('ValueInterpreterDisplay', () => { testNumberFormatCombinations(formatData, combinationsForNumbers); }); - it('correctly LinearMemoryInspector.ValueInterpreterDisplayUtils.formats floats in decimal mode', async () => { + it('correctly formats floats in decimal mode', async () => { const expectedFloat = 341.34; const actualValue = LinearMemoryInspector.ValueInterpreterDisplayUtils.formatFloat( expectedFloat, LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueTypeMode.Decimal); assert.strictEqual(actualValue, '341.34'); }); - it('correctly LinearMemoryInspector.ValueInterpreterDisplayUtils.formats floats in scientific mode', async () => { + it('correctly formats floats in scientific mode', async () => { const expectedFloat = 341.34; const actualValue = LinearMemoryInspector.ValueInterpreterDisplayUtils.formatFloat( expectedFloat, LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueTypeMode.Scientific); assert.strictEqual(actualValue, '3.41e+2'); }); - it('correctly LinearMemoryInspector.ValueInterpreterDisplayUtils.formats integers in decimal mode', async () => { + it('correctly formats integers in decimal mode', async () => { const expectedInteger = 120; const actualValue = LinearMemoryInspector.ValueInterpreterDisplayUtils.formatInteger( expectedInteger, LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueTypeMode.Decimal); assert.strictEqual(actualValue, '120'); }); - it('correctly LinearMemoryInspector.ValueInterpreterDisplayUtils.formats integers in hexadecimal mode', async () => { + it('correctly formats integers in hexadecimal mode', async () => { const expectedInteger = 16; const actualValue = LinearMemoryInspector.ValueInterpreterDisplayUtils.formatInteger( expectedInteger, LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueTypeMode.Hexadecimal); assert.strictEqual(actualValue, '10'); }); - it('correctly LinearMemoryInspector.ValueInterpreterDisplayUtils.formats integers in octal mode', async () => { + it('correctly formats integers in octal mode', async () => { const expectedInteger = 16; const actualValue = LinearMemoryInspector.ValueInterpreterDisplayUtils.formatInteger( expectedInteger, LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueTypeMode.Octal); assert.strictEqual(actualValue, '20'); }); - it('correctly LinearMemoryInspector.ValueInterpreterDisplayUtils.formats integers in octal mode', async () => { + it('correctly formats integers in octal mode', async () => { const expectedInteger = 16; const actualValue = LinearMemoryInspector.ValueInterpreterDisplayUtils.formatInteger( expectedInteger, LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueTypeMode.Octal); diff --git a/test/unittests/front_end/linear_memory_inspector/ValueInterpreterSettings_test.ts b/test/unittests/front_end/linear_memory_inspector/ValueInterpreterSettings_test.ts index b8206400ab..4dd0608d94 100644 --- a/test/unittests/front_end/linear_memory_inspector/ValueInterpreterSettings_test.ts +++ b/test/unittests/front_end/linear_memory_inspector/ValueInterpreterSettings_test.ts @@ -28,14 +28,21 @@ describe('ValueInterpreterSettings', () => { it('renders all checkboxes', async () => { const {component} = setUpComponent(); const checkboxes = getElementsWithinComponent(component, SETTINGS_LABEL_SELECTOR, HTMLLabelElement); - - assert.lengthOf(checkboxes, Object.values(LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType).length); + const checkboxLabels = Array.from(checkboxes, checkbox => checkbox.getAttribute('title')); + assert.deepEqual(checkboxLabels, [ + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.Int8, + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.Int16, + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.Int32, + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.Int64, + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.Float32, + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.Float64, + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.String, + ]); }); it('triggers an event on checkbox click', async () => { const {component} = setUpComponent(); const labels = getElementsWithinComponent(component, SETTINGS_LABEL_SELECTOR, HTMLLabelElement); - assert.lengthOf(labels, Object.values(LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType).length); for (const label of labels) { const checkbox = label.querySelector(SETTINGS_INPUT_SELECTOR); @@ -71,8 +78,15 @@ describe('ValueInterpreterSettings', () => { assert.deepEqual(checkedTitles, expectedTitles); const uncheckedTitles = new Set(elements.filter(n => !n.checked).map(n => n.title.innerText)); - const allTypesTitle = - Object.values(LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType).map(type => `${type}`); + const allTypesTitle = [ + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.Int8, + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.Int16, + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.Int32, + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.Int64, + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.Float32, + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.Float64, + LinearMemoryInspector.ValueInterpreterDisplayUtils.ValueType.String, + ]; const expectedUncheckedTitles = new Set(allTypesTitle.filter(title => !expectedTitles.has(title))); assert.deepEqual(uncheckedTitles, expectedUncheckedTitles); });