Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
10 changes: 5 additions & 5 deletions test/js/rbs/combination.txt
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion test/js/rbs/optional.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
untyped?
^-> untyped?
untyped | void?
untyped | bool?
:foo??
:foo!?
4 changes: 0 additions & 4 deletions test/js/rbs/plain.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
void
untyped
bool
true
false
nil
top
bot
self
instance
class
8 changes: 4 additions & 4 deletions test/js/rbs/proc.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 15 additions & 1 deletion test/js/rbs/rbs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
2 changes: 1 addition & 1 deletion test/js/rbs/tuple.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[ ]
[untyped, nil, void]
[untyped, nil, bool]
[untyped]