amberjs 1.17.0

JavaScript/TypeScript runtime built with Rust and V8
Documentation
// V8 Bindings for Testing Framework - Fixed version
/// Registers test() / describe() / expect() functions in V8 context
use rusty_v8 as v8;
/// Register all testing functions in the V8 global scope
pub fn register_testing_api(_scope: &mut v8::PinScope, _global: v8::Local<v8::Object>) {
    // Temporarily disabled due to V8 API complexity
    // Will be re-enabled in future stages
    if cfg!(feature = "verbose_logging") {
        eprintln!("✅ Registered testing API in V8 context");
    }
}

#[allow(dead_code)]
/// test() callback - registers a test case
fn test_callback(
    scope: &mut v8::PinScope,
    args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    let name: _ = args.get(0).to_rust_string_lossy(scope);
    let function: _ = args.get(1);
    if !function.is_function() {
        let error: _ =
            v8::String::new(scope, "test() requires a function as second argument").unwrap();
        let exception: _ = v8::Exception::error(scope, error);
        scope.throw_exception(exception);
        return;
    }
    let _func: _ = v8::Local::<v8::Function>::try_from(args.get(1)).unwrap();
    // Temporarily disabled test registration
    // Will be re-implemented with proper V8 function handling
    if cfg!(feature = "verbose_logging") {
        eprintln!("📝 Registered test: {}", name);
    }
    retval.set(v8::undefined(scope).into());
}

#[allow(dead_code)]
/// describe() callback - creates a test suite
fn describe_callback(
    scope: &mut v8::PinScope,
    args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    let _name: _ = args.get(0).to_rust_string_lossy(scope);
    // For now, just return undefined
    // TODO: Implement suite registration
    retval.set(v8::undefined(scope).into());
}

#[allow(dead_code)]
/// it() callback - alias for test()
fn it_callback(
    scope: &mut v8::PinScope,
    args: v8::FunctionCallbackArguments,
    retval: v8::ReturnValue,
) {
    test_callback(scope, args, retval);
}

#[allow(dead_code)]
/// expect() callback - creates an expectation object
fn expect_callback(
    scope: &mut v8::PinScope,
    args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    let _value: _ = args.get(0);
    // Create a simple expect object (matchers disabled for now)
    let expect_obj: _ = v8::Object::new(scope);
    retval.set(expect_obj.into());
}

#[allow(dead_code)]
/// beforeEach() callback
fn before_each_callback(
    scope: &mut v8::PinScope,
    _args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    // Store beforeEach hook for the current suite
    if cfg!(feature = "verbose_logging") {
        eprintln!("🔧 Registered beforeEach hook");
    }
    retval.set(v8::undefined(scope).into());
}

#[allow(dead_code)]
/// afterEach() callback
fn after_each_callback(
    scope: &mut v8::PinScope,
    _args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    if cfg!(feature = "verbose_logging") {
        eprintln!("🔧 Registered afterEach hook");
    }
    retval.set(v8::undefined(scope).into());
}

#[allow(dead_code)]
/// beforeAll() callback
fn before_all_callback(
    scope: &mut v8::PinScope,
    _args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    if cfg!(feature = "verbose_logging") {
        eprintln!("🔧 Registered beforeAll hook");
    }
    retval.set(v8::undefined(scope).into());
}

#[allow(dead_code)]
/// afterAll() callback
fn after_all_callback(
    scope: &mut v8::PinScope,
    _args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    if cfg!(feature = "verbose_logging") {
        eprintln!("🔧 Registered afterAll hook");
    }
    retval.set(v8::undefined(scope).into());
}

#[allow(dead_code)]
/// skip() callback
fn skip_callback(
    scope: &mut v8::PinScope,
    _args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    retval.set(v8::undefined(scope).into());
}

#[allow(dead_code)]
/// only() callback
fn only_callback(
    scope: &mut v8::PinScope,
    _args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    retval.set(v8::undefined(scope).into());
}
/// toBe matcher - strict equality
#[allow(dead_code)]
fn to_be_matcher(
    scope: &mut v8::PinScope,
    args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    let _expected: _ = args.get(0);
    // Simple implementation - just return true for now
    retval.set(v8::Boolean::new(scope, true).into());
}
/// toEqual matcher - deep equality
#[allow(dead_code)]
fn to_equal_matcher(
    scope: &mut v8::PinScope,
    args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    let _expected: _ = args.get(0);
    // Simple implementation - just return true for now
    retval.set(v8::Boolean::new(scope, true).into());
}
/// toBeTruthy matcher
#[allow(dead_code)]
fn to_be_truthy_matcher(
    scope: &mut v8::PinScope,
    _args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    retval.set(v8::Boolean::new(scope, true).into());
}
/// toBeFalsy matcher
#[allow(dead_code)]
fn to_be_falsy_matcher(
    scope: &mut v8::PinScope,
    _args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    retval.set(v8::Boolean::new(scope, true).into());
}
/// toContain matcher
#[allow(dead_code)]
fn to_contain_matcher(
    scope: &mut v8::PinScope,
    _args: v8::FunctionCallbackArguments,
    mut retval: v8::ReturnValue,
) {
    retval.set(v8::Boolean::new(scope, true).into());
}