Skip to content
Merged
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
7 changes: 7 additions & 0 deletions ext/smarter_json/smarter_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -1629,9 +1629,16 @@ static VALUE fj_parse_c(VALUE self, VALUE input, VALUE opts) {

void Init_smarter_json(void) {
mSmarterJSON = rb_define_module("SmarterJSON");

rb_global_variable(&cParseError);
cParseError = rb_const_get(mSmarterJSON, rb_intern("ParseError"));

rb_global_variable(&cEncodingError);
cEncodingError = rb_const_get(mSmarterJSON, rb_intern("EncodingError"));

rb_global_variable(&cWarning);
cWarning = rb_const_get(mSmarterJSON, rb_intern("Warning"));

fj_bigdecimal_id = rb_intern("BigDecimal");
fj_to_sym_id = rb_intern("to_sym");
fj_key_p_id = rb_intern("key?");
Expand Down
10 changes: 10 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@

require "smarter_json"

if GC.respond_to?(:verify_compaction_references)
# This method was added in Ruby 3.0.0. Calling it this way asks the GC to
# move objects around, helping to find object movement bugs.
begin
GC.verify_compaction_references(expand_heap: true, toward: :empty)
rescue NotImplementedError, ArgumentError
# Some platforms don't support compaction
end
end

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
Expand Down