1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/spec/c/string_spec.rb

30 lines
867 B
Ruby
Raw Normal View History

require 'c_spec_helper'
describe V8::C::String do
requires_v8_context
2015-03-21 10:54:39 +00:00
it 'is a primitive' do
expect(V8::C::String.NewFromUtf8(@isolate, 'test')).to be_a V8::C::Primitive
2015-03-21 10:54:39 +00:00
end
it 'can create new strings' do
expect(V8::C::String.NewFromUtf8(@isolate, 'test')).to be
end
it 'can be converted to a ruby string' do
expect(V8::C::String.NewFromUtf8(@isolate, 'test').Utf8Value).to eq 'test'
end
it 'can hold Unicode values outside the Basic Multilingual Plane' do
string = V8::C::String.NewFromUtf8(@isolate, "\u{100000}")
expect(string.Utf8Value).to eq "\u{100000}"
end
it 'can concatenate strings' do
string_one = V8::C::String.NewFromUtf8(@isolate, 'Hello ')
string_two = V8::C::String.NewFromUtf8(@isolate, 'World!')
expect(V8::C::String.Concat(string_one, string_two).Utf8Value).to eq 'Hello World!'
end
end