diff --git a/src/server.rb b/src/server.rb index d5876cf7..7c281ff0 100644 --- a/src/server.rb +++ b/src/server.rb @@ -136,16 +136,16 @@ end if response - socket.write(JSON.fast_generate(response.force_encoding("UTF-8"))) + socket.write(JSON.generate(response.force_encoding("UTF-8"))) else socket.write("{ \"error\": true }") end rescue SyntaxTree::Parser::ParseError => error loc = { start: { line: error.lineno, column: error.column } } - socket.write(JSON.fast_generate(error: error.message, loc: loc)) + socket.write(JSON.generate(error: error.message, loc: loc)) rescue StandardError => error begin - socket.write(JSON.fast_generate(error: error.message)) + socket.write(JSON.generate(error: error.message)) rescue Errno::EPIPE # Do nothing, the pipe has been closed by the parent process so we # don't actually care about writing to it anymore. @@ -163,5 +163,5 @@ end end -File.write(connection_filepath, JSON.fast_generate(connection_information)) +File.write(connection_filepath, JSON.generate(connection_information)) listener.join diff --git a/test/js/rbs/combination.txt b/test/js/rbs/combination.txt index 2761e7a7..5a9ae9e2 100644 --- a/test/js/rbs/combination.txt +++ b/test/js/rbs/combination.txt @@ -1,5 +1,5 @@ -untyped | void | nil -untyped & void & nil -untyped | void & nil -untyped & void | nil -untyped & (void | nil) +untyped | bool | nil +untyped & bool & nil +untyped | bool & nil +untyped & bool | nil +untyped & (bool | nil) diff --git a/test/js/rbs/optional.txt b/test/js/rbs/optional.txt index e7842ee6..65fc51b6 100644 --- a/test/js/rbs/optional.txt +++ b/test/js/rbs/optional.txt @@ -1,5 +1,5 @@ untyped? ^-> untyped? -untyped | void? +untyped | bool? :foo?? :foo!? diff --git a/test/js/rbs/plain.txt b/test/js/rbs/plain.txt index 99ab75f5..bc45ed4c 100644 --- a/test/js/rbs/plain.txt +++ b/test/js/rbs/plain.txt @@ -1,4 +1,3 @@ -void untyped bool true @@ -6,6 +5,3 @@ false nil top bot -self -instance -class diff --git a/test/js/rbs/proc.txt b/test/js/rbs/proc.txt index 4d77333b..f7eaeac8 100644 --- a/test/js/rbs/proc.txt +++ b/test/js/rbs/proc.txt @@ -1,9 +1,9 @@ ^-> void ^(untyped) -> void -^(untyped, void) -> void -^(untyped x, void _y) -> void -^(untyped x, ?void, ?nil y) -> void -^(untyped x, ?void, ?nil y, *untyped a) -> void +^(untyped, bool) -> void +^(untyped x, bool _y) -> void +^(untyped x, ?bool, ?nil y) -> void +^(untyped x, ?bool, ?nil y, *untyped a) -> void ^(untyped x, *untyped a, nil z) -> void ^(foo: untyped, _bar: nil bar) -> void ^(?_bar: nil, **untyped rest) -> void diff --git a/test/js/rbs/rbs.test.js b/test/js/rbs/rbs.test.js index 3e6addac..c45974af 100644 --- a/test/js/rbs/rbs.test.js +++ b/test/js/rbs/rbs.test.js @@ -283,7 +283,21 @@ describe("rbs", () => { }); }); - describeCases("plain", (source) => `T: ${source}`); + describe("plain", () => { + testCases("plain", (source) => `T: ${source}`); + + ["void", "self", "instance", "class"].forEach((source) => { + test(source, () => { + const content = rbs(` + class T + def t: -> ${source} + end + `); + + return expect(content).toMatchFormat(); + }); + }); + }); describe("proc", () => { testCases("proc", (source) => `T: ${source}`); diff --git a/test/js/rbs/tuple.txt b/test/js/rbs/tuple.txt index 7dd425e4..2f82dfa4 100644 --- a/test/js/rbs/tuple.txt +++ b/test/js/rbs/tuple.txt @@ -1,3 +1,3 @@ [ ] -[untyped, nil, void] +[untyped, nil, bool] [untyped]