Skip to content

Commit

Permalink
doc test for to_string_tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo Ceccato authored and Angelo Ceccato committed Feb 18, 2024
1 parent 3ec6e58 commit c5e0b76
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion core/engine/src/object/builtins/jstypedarray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,25 @@ impl JsTypedArray {
})
}

/// Calls `TypedArray.prototype.toStringTag()`.
/// It is a getter that returns the same string as the typed array constructor's name.
/// It returns `Ok(JsValue::Undefined)` if the this value is not one of the typed array subclasses.
///
/// Returns `TypedArray.prototype.toStringTag()`.
///
/// # Examples
///
/// ```
/// # use boa_engine::{JsResult, js_string, object::{builtins::{JsUint8Array}}, Context};
/// # fn main() -> JsResult<()> {
///
/// let context = &mut Context::default();
/// let array = JsUint8Array::from_iter(vec![1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8], context)?;
/// let tag = array.to_string_tag(context)?.to_string(context)?;
/// assert_eq!(tag, js_string!("Uint8Array"));
///
/// # Ok(())
/// # }
/// ```
#[inline]
pub fn to_string_tag(&self, context: &mut Context) -> JsResult<JsValue> {
BuiltinTypedArray::to_string_tag(&self.inner.clone().into(), &[], context)
Expand Down

0 comments on commit c5e0b76

Please sign in to comment.