diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/CommandTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/CommandTest.js index c4855515605a25..dd08a012c4bf57 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/CommandTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/CommandTest.js @@ -8,11 +8,11 @@ import { Command } from '../src/Command.js'; test('parses simple command', () => { let obj = { - "name": "setBreakpointsActive", - "parameters": [ - { "name": "active", "type": "boolean", "description": "New value for breakpoints active state." } + 'name': 'setBreakpointsActive', + 'parameters': [ + { 'name': 'active', 'type': 'boolean', 'description': 'New value for breakpoints active state.' }, ], - "description": "Activates / deactivates all breakpoints on the page." + 'description': 'Activates / deactivates all breakpoints on the page.', }; let command = Command.create('Debugger', obj, false); @@ -31,16 +31,16 @@ test('parses simple command', () => { test('parses command with return', () => { let obj = { - "name": "setBreakpoint", - "parameters": [ - { "name": "location", "$ref": "Location", "description": "Location to set breakpoint in." }, - { "name": "condition", "type": "string", "optional": true, "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true." } + 'name': 'setBreakpoint', + 'parameters': [ + { 'name': 'location', '$ref': 'Location', 'description': 'Location to set breakpoint in.' }, + { 'name': 'condition', 'type': 'string', 'optional': true, 'description': 'Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.' }, ], - "returns": [ - { "name": "breakpointId", "$ref": "BreakpointId", "description": "Id of the created breakpoint for further reference." }, - { "name": "actualLocation", "$ref": "Location", "description": "Location this breakpoint resolved into." } + 'returns': [ + { 'name': 'breakpointId', '$ref': 'BreakpointId', 'description': 'Id of the created breakpoint for further reference.' }, + { 'name': 'actualLocation', '$ref': 'Location', 'description': 'Location this breakpoint resolved into.' }, ], - "description": "Sets JavaScript breakpoint at a given location." + 'description': 'Sets JavaScript breakpoint at a given location.', }; let command = Command.create('Debugger', obj, false); diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/EventTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/EventTest.js index 8028e1054ae5e1..5ef40d749c5c52 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/EventTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/EventTest.js @@ -8,8 +8,8 @@ import { Event } from '../src/Event.js'; test('parses simple event', () => { let obj = { - "name": "resumed", - "description": "Fired when the virtual machine resumed execution." + 'name': 'resumed', + 'description': 'Fired when the virtual machine resumed execution.', }; let event = Event.create('Debugger', obj, false); @@ -25,12 +25,12 @@ test('parses simple event', () => { test('parses event with params', () => { let obj = { - "name": "breakpointResolved", - "parameters": [ - { "name": "breakpointId", "$ref": "BreakpointId", "description": "Breakpoint unique identifier." }, - { "name": "location", "$ref": "Location", "description": "Actual breakpoint location." } + 'name': 'breakpointResolved', + 'parameters': [ + { 'name': 'breakpointId', '$ref': 'BreakpointId', 'description': 'Breakpoint unique identifier.' }, + { 'name': 'location', '$ref': 'Location', 'description': 'Actual breakpoint location.' }, ], - "description": "Fired when breakpoint is resolved to an actual script and location." + 'description': 'Fired when breakpoint is resolved to an actual script and location.', }; let event = Event.create('Debugger', obj, false); diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/HeaderWriterTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/HeaderWriterTest.js index b04b6ffcee5255..d77742d54a481e 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/HeaderWriterTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/HeaderWriterTest.js @@ -23,14 +23,14 @@ beforeEach(() => { test('emits type decl', () => { let obj = { - "id": "Location", - "type": "object", - "properties": [ - { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier as reported in the Debugger.scriptParsed." }, - { "name": "lineNumber", "type": "integer", "description": "Line number in the script (0-based)." }, - { "name": "columnNumber", "type": "integer", "optional": true, "description": "Column number in the script (0-based)." } + 'id': 'Location', + 'type': 'object', + 'properties': [ + { 'name': 'scriptId', '$ref': 'Runtime.ScriptId', 'description': 'Script identifier as reported in the Debugger.scriptParsed.' }, + { 'name': 'lineNumber', 'type': 'integer', 'description': 'Line number in the script (0-based).' }, + { 'name': 'columnNumber', 'type': 'integer', 'optional': true, 'description': 'Column number in the script (0-based).' }, ], - "description": "Location in the source code." + 'description': 'Location in the source code.', }; let type = Type.create('Debugger', obj); @@ -51,14 +51,14 @@ test('emits type decl', () => { test('emits request decl', () => { let obj = { - "name": "getScriptSource", - "parameters": [ - { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to get source for." } + 'name': 'getScriptSource', + 'parameters': [ + { 'name': 'scriptId', '$ref': 'Runtime.ScriptId', 'description': 'Id of the script to get source for.' }, ], - "returns": [ - { "name": "scriptSource", "type": "string", "description": "Script source." } + 'returns': [ + { 'name': 'scriptSource', 'type': 'string', 'description': 'Script source.' }, ], - "description": "Returns source for the script with given id." + 'description': 'Returns source for the script with given id.', }; let command = Command.create('Debugger', obj); @@ -79,14 +79,14 @@ test('emits request decl', () => { test('emits response decl', () => { let obj = { - "name": "getScriptSource", - "parameters": [ - { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to get source for." } + 'name': 'getScriptSource', + 'parameters': [ + { 'name': 'scriptId', '$ref': 'Runtime.ScriptId', 'description': 'Id of the script to get source for.' }, ], - "returns": [ - { "name": "scriptSource", "type": "string", "description": "Script source." } + 'returns': [ + { 'name': 'scriptSource', 'type': 'string', 'description': 'Script source.' }, ], - "description": "Returns source for the script with given id." + 'description': 'Returns source for the script with given id.', }; let command = Command.create('Debugger', obj); @@ -105,11 +105,11 @@ test('emits response decl', () => { test('emits notification decl', () => { let obj = { - "name": "messageAdded", - "parameters": [ - { "name": "message", "$ref": "ConsoleMessage", "description": "Console message that has been added." } + 'name': 'messageAdded', + 'parameters': [ + { 'name': 'message', '$ref': 'ConsoleMessage', 'description': 'Console message that has been added.' }, ], - "description": "Issued when new console message is added." + 'description': 'Issued when new console message is added.', }; let event = Event.create('Console', obj); diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/ImplementationWriterTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/ImplementationWriterTest.js index 8485cb7fe2fb41..13139401da151e 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/ImplementationWriterTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/ImplementationWriterTest.js @@ -9,7 +9,7 @@ import { emitNotificationDef, emitRequestDef, emitResponseDef, - emitTypeDef + emitTypeDef, } from '../src/ImplementationWriter'; import { Event } from '../src/Event'; import { Command } from '../src/Command'; @@ -23,14 +23,14 @@ beforeEach(() => { test('emits type def', () => { let obj = { - "id": "Location", - "type": "object", - "properties": [ - { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier as reported in the Debugger.scriptParsed." }, - { "name": "lineNumber", "type": "integer", "description": "Line number in the script (0-based)." }, - { "name": "columnNumber", "type": "integer", "optional": true, "description": "Column number in the script (0-based)." } + 'id': 'Location', + 'type': 'object', + 'properties': [ + { 'name': 'scriptId', '$ref': 'Runtime.ScriptId', 'description': 'Script identifier as reported in the Debugger.scriptParsed.' }, + { 'name': 'lineNumber', 'type': 'integer', 'description': 'Line number in the script (0-based).' }, + { 'name': 'columnNumber', 'type': 'integer', 'optional': true, 'description': 'Column number in the script (0-based).' }, ], - "description": "Location in the source code." + 'description': 'Location in the source code.', }; let type = Type.create('Debugger', obj); @@ -55,14 +55,14 @@ test('emits type def', () => { test('emits request def', () => { let obj = { - "name": "getScriptSource", - "parameters": [ - { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to get source for." } + 'name': 'getScriptSource', + 'parameters': [ + { 'name': 'scriptId', '$ref': 'Runtime.ScriptId', 'description': 'Id of the script to get source for.' }, ], - "returns": [ - { "name": "scriptSource", "type": "string", "description": "Script source." } + 'returns': [ + { 'name': 'scriptSource', 'type': 'string', 'description': 'Script source.' }, ], - "description": "Returns source for the script with given id." + 'description': 'Returns source for the script with given id.', }; let command = Command.create('Debugger', obj); @@ -100,14 +100,14 @@ test('emits request def', () => { test('emits response def', () => { let obj = { - "name": "getScriptSource", - "parameters": [ - { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to get source for." } + 'name': 'getScriptSource', + 'parameters': [ + { 'name': 'scriptId', '$ref': 'Runtime.ScriptId', 'description': 'Id of the script to get source for.' }, ], - "returns": [ - { "name": "scriptSource", "type": "string", "description": "Script source." } + 'returns': [ + { 'name': 'scriptSource', 'type': 'string', 'description': 'Script source.' }, ], - "description": "Returns source for the script with given id." + 'description': 'Returns source for the script with given id.', }; let command = Command.create('Debugger', obj); @@ -135,11 +135,11 @@ test('emits response def', () => { test('emits notification def', () => { let obj = { - "name": "messageAdded", - "parameters": [ - { "name": "message", "$ref": "ConsoleMessage", "description": "Console message that has been added." } + 'name': 'messageAdded', + 'parameters': [ + { 'name': 'message', '$ref': 'ConsoleMessage', 'description': 'Console message that has been added.' }, ], - "description": "Issued when new console message is added." + 'description': 'Issued when new console message is added.', }; let event = Event.create('Console', obj); diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/PropertyTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/PropertyTest.js index 6b4e600324b3cf..3e4d468f1f42f7 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/PropertyTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/PropertyTest.js @@ -8,9 +8,9 @@ import { Property } from '../src/Property.js'; test('parses required primitive prop', () => { let obj = { - "name": "lineNumber", - "type": "integer", - "description": "Line number in the script (0-based)." + 'name': 'lineNumber', + 'type': 'integer', + 'description': 'Line number in the script (0-based).', }; let prop = Property.create('Debugger', obj); @@ -27,10 +27,10 @@ test('parses required primitive prop', () => { test('parses optional primitive prop', () => { let obj = { - "name": "samplingInterval", - "type": "number", - "optional": true, - "description": "Average sample interval in bytes." + 'name': 'samplingInterval', + 'type': 'number', + 'optional': true, + 'description': 'Average sample interval in bytes.', }; let prop = Property.create('HeapProfiler', obj); @@ -47,10 +47,10 @@ test('parses optional primitive prop', () => { test('parses optional ref prop', () => { let obj = { - "name": "exceptionDetails", - "optional": true, - "$ref": "Runtime.ExceptionDetails", - "description": "Exception details if any." + 'name': 'exceptionDetails', + 'optional': true, + '$ref': 'Runtime.ExceptionDetails', + 'description': 'Exception details if any.', }; let prop = Property.create('Debugger', obj); @@ -67,11 +67,11 @@ test('parses optional ref prop', () => { test('parses recursive ref prop', () => { let obj = { - "name": "parent", - "$ref": "StackTrace", - "optional": true, - "recursive": true, - "description": "Asynchronous JavaScript stack trace..." + 'name': 'parent', + '$ref': 'StackTrace', + 'optional': true, + 'recursive': true, + 'description': 'Asynchronous JavaScript stack trace...', }; let prop = Property.create('Runtime', obj); @@ -89,11 +89,11 @@ test('parses recursive ref prop', () => { test('parses optional array items prop', () => { let obj = { - "name": "hitBreakpoints", - "type": "array", - "optional": true, - "items": { "type": "string" }, - "description": "Hit breakpoints IDs" + 'name': 'hitBreakpoints', + 'type': 'array', + 'optional': true, + 'items': { 'type': 'string' }, + 'description': 'Hit breakpoints IDs', }; let prop = Property.create('Debugger', obj); @@ -101,8 +101,8 @@ test('parses optional array items prop', () => { expect(prop.name).toBe('hitBreakpoints'); expect(prop.type).toBe('array'); expect(prop.optional).toBe(true); - expect(prop.items).toEqual({ "type": "string" }); - expect(prop.description).toBe("Hit breakpoints IDs"); + expect(prop.items).toEqual({ 'type': 'string' }); + expect(prop.description).toBe('Hit breakpoints IDs'); expect(prop.getFullCppType()).toBe('folly::Optional>'); expect(prop.getCppIdentifier()).toBe('hitBreakpoints'); @@ -111,18 +111,18 @@ test('parses optional array items prop', () => { test('parses array ref prop', () => { let obj = { - "name": "domains", - "type": "array", - "items": { "$ref": "Domain" }, - "description": "List of supported domains." + 'name': 'domains', + 'type': 'array', + 'items': { '$ref': 'Domain' }, + 'description': 'List of supported domains.', }; let prop = Property.create('Schema', obj); expect(prop.domain).toBe('Schema'); expect(prop.name).toBe('domains'); expect(prop.type).toBe('array'); - expect(prop.items).toEqual({ $ref: "Domain" }); - expect(prop.description).toBe("List of supported domains."); + expect(prop.items).toEqual({ $ref: 'Domain' }); + expect(prop.description).toBe('List of supported domains.'); expect(prop.getFullCppType()).toBe('std::vector'); expect(prop.getCppIdentifier()).toBe('domains'); diff --git a/ReactCommon/hermes/inspector/tools/msggen/__tests__/TypeTest.js b/ReactCommon/hermes/inspector/tools/msggen/__tests__/TypeTest.js index 6e8a16e32e5e61..66a697a0cd4ebd 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/__tests__/TypeTest.js +++ b/ReactCommon/hermes/inspector/tools/msggen/__tests__/TypeTest.js @@ -8,9 +8,9 @@ import { Type } from '../src/Type.js'; test('parses primitive type', () => { let obj = { - "id": "Timestamp", - "type": "number", - "description": "Number of milliseconds since epoch." + 'id': 'Timestamp', + 'type': 'number', + 'description': 'Number of milliseconds since epoch.', }; let type = Type.create('Runtime', obj, false); @@ -26,14 +26,14 @@ test('parses primitive type', () => { test('parses object type', () => { let obj = { - "id": "Location", - "type": "object", - "properties": [ - { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier as reported in the Debugger.scriptParsed." }, - { "name": "lineNumber", "type": "integer", "description": "Line number in the script (0-based)." }, - { "name": "columnNumber", "type": "integer", "optional": true, "description": "Column number in the script (0-based)." } + 'id': 'Location', + 'type': 'object', + 'properties': [ + { 'name': 'scriptId', '$ref': 'Runtime.ScriptId', 'description': 'Script identifier as reported in the Debugger.scriptParsed.' }, + { 'name': 'lineNumber', 'type': 'integer', 'description': 'Line number in the script (0-based).' }, + { 'name': 'columnNumber', 'type': 'integer', 'optional': true, 'description': 'Column number in the script (0-based).' }, ], - "description": "Location in the source code." + 'description': 'Location in the source code.', }; let type = Type.create('Debugger', obj, false); diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/ImplementationWriter.js b/ReactCommon/hermes/inspector/tools/msggen/src/ImplementationWriter.js index 74ca424c1e8839..3f0497eaa90ebb 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/ImplementationWriter.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/ImplementationWriter.js @@ -265,7 +265,7 @@ export function emitRequestDef(stream: Writable, command: Command) { assign(method, obj, "method");\n\n`); if (props.length > 0) { - stream.write(`dynamic params = obj.at("params");\n`); + stream.write('dynamic params = obj.at("params");\n'); for (const prop of props) { const id = prop.getCppIdentifier(); @@ -280,7 +280,7 @@ export function emitRequestDef(stream: Writable, command: Command) { stream.write(`dynamic ${cppNs}::${cppType}::toDynamic() const {\n`); if (props.length > 0) { - stream.write(`dynamic params = dynamic::object;\n`); + stream.write('dynamic params = dynamic::object;\n'); for (const prop of props) { const id = prop.getCppIdentifier(); @@ -296,7 +296,7 @@ export function emitRequestDef(stream: Writable, command: Command) { `); if (props.length > 0) { - stream.write(`put(obj, "params", std::move(params));\n`); + stream.write('put(obj, "params", std::move(params));\n'); } stream.write(`return obj; @@ -321,7 +321,7 @@ export function emitResponseDef(stream: Writable, command: Command) { const props = command.returns || []; if (props.length > 0) { - stream.write(`dynamic res = obj.at("result");\n`); + stream.write('dynamic res = obj.at("result");\n'); for (const prop of props) { const id = prop.getCppIdentifier(); @@ -336,7 +336,7 @@ export function emitResponseDef(stream: Writable, command: Command) { stream.write(`dynamic ${cppNs}::${cppType}::toDynamic() const {\n`); if (props.length > 0) { - stream.write(`dynamic res = dynamic::object;\n`); + stream.write('dynamic res = dynamic::object;\n'); for (const prop of props) { const id = prop.getCppIdentifier(); @@ -369,7 +369,7 @@ export function emitNotificationDef(stream: Writable, event: Event) { assign(method, obj, "method");\n\n`); if (props.length > 0) { - stream.write(`dynamic params = obj.at("params");\n`); + stream.write('dynamic params = obj.at("params");\n'); for (const prop of props) { const id = prop.getCppIdentifier(); @@ -384,7 +384,7 @@ export function emitNotificationDef(stream: Writable, event: Event) { stream.write(`dynamic ${cppNs}::${cppType}::toDynamic() const {\n`); if (props.length > 0) { - stream.write(`dynamic params = dynamic::object;\n`); + stream.write('dynamic params = dynamic::object;\n'); for (const prop of props) { const id = prop.getCppIdentifier(); @@ -399,7 +399,7 @@ export function emitNotificationDef(stream: Writable, event: Event) { `); if (props.length > 0) { - stream.write(`put(obj, "params", std::move(params));\n`); + stream.write('put(obj, "params", std::move(params));\n'); } stream.write(`return obj; diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/TestHelpers.js b/ReactCommon/hermes/inspector/tools/msggen/src/TestHelpers.js index 1f7bc6ee961c1c..b54300d53fd5ef 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/TestHelpers.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/TestHelpers.js @@ -1,6 +1,8 @@ /** * Copyright 2004-present Facebook. All Rights Reserved. */ + /*global expect*/ + 'use strict'; // munges string so that it's nice to look at in a test diff