summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-complex
diff options
context:
space:
mode:
Diffstat (limited to 'mrbgems/mruby-complex')
-rw-r--r--mrbgems/mruby-complex/src/complex.c1
-rw-r--r--mrbgems/mruby-complex/test/complex.rb8
2 files changed, 8 insertions, 1 deletions
diff --git a/mrbgems/mruby-complex/src/complex.c b/mrbgems/mruby-complex/src/complex.c
index c6fb7a829..1b030c317 100644
--- a/mrbgems/mruby-complex/src/complex.c
+++ b/mrbgems/mruby-complex/src/complex.c
@@ -24,6 +24,7 @@ complex_new(mrb_state *mrb, mrb_float real, mrb_float imaginary)
struct mrb_complex *p = complex_ptr(mrb, comp);
p->real = real;
p->imaginary = imaginary;
+ MRB_SET_FROZEN_FLAG(s);
return comp;
}
diff --git a/mrbgems/mruby-complex/test/complex.rb b/mrbgems/mruby-complex/test/complex.rb
index e7fcc7322..6996eb214 100644
--- a/mrbgems/mruby-complex/test/complex.rb
+++ b/mrbgems/mruby-complex/test/complex.rb
@@ -1,5 +1,5 @@
def assert_complex(real, exp)
- assert_float real.real, exp.real
+ assert_float real.real, exp.real
assert_float real.imaginary, exp.imaginary
end
@@ -126,3 +126,9 @@ assert 'Complex::to_i' do
Complex(1, 2).to_i
end
end
+
+assert 'Complex#frozen?' do
+ assert_predicate(1i, :frozen?)
+ assert_predicate(Complex(2,3), :frozen?)
+ assert_predicate(4+5i, :frozen?)
+end