// warning: This file is auto generated by `yarn build:tests` // Do not edit by hand! import { createRequire } from 'node:module' import { describe, it, expect } from 'vitest' process.env.TZ = 'UTC' const __locutus_source_fn = require('../../../../src/python/operator/or_.ts').or_ const __locutus_source_module_url = new URL("../../../../src/python/operator/or_.ts", import.meta.url) const __locutus_source_require = createRequire(__locutus_source_module_url) const __locutus_func_name = "or_" const __locutus_module_js_code = "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.or_ = or_;\nconst _operator_ts_1 = require(\"../_helpers/_operator.ts\");\nfunction or_(a, b) {\n // discuss at: https://locutus.io/python/operator/or_/\n // parity verified: Python 3.12\n // original by: Kevin van Zonneveld (https://kvz.io)\n // note 1: Performs Python-style bitwise or on integer-like values.\n // example 1: or_(4, 1)\n // returns 1: 5\n // example 2: or_(true, false)\n // returns 2: true\n return (0, _operator_ts_1.pythonBitOr)(a, b, 'or_');\n}" const __locutus_standalone_ts_code = "// python/_helpers/_operator (Locutus helper dependency)\nfunction toPythonInteger(value, functionName) {\n if (typeof value === 'boolean') {\n return value ? 1n : 0n;\n }\n if (typeof value === 'bigint') {\n return value;\n }\n if (typeof value === 'number' && Number.isFinite(value) && Number.isSafeInteger(value)) {\n return BigInt(value);\n }\n throw new TypeError(`${functionName}() expected an integer value`);\n}\nfunction fromPythonInteger(value, functionName) {\n const numericValue = Number(value);\n if (!Number.isSafeInteger(numericValue)) {\n throw new RangeError(`${functionName}() result does not fit within JS safe integer precision`);\n }\n return numericValue;\n}\nfunction pythonBitOr(left, right, functionName) {\n const leftInt = toPythonInteger(left, functionName);\n const rightInt = toPythonInteger(right, functionName);\n const result = leftInt | rightInt;\n return typeof left === 'boolean' && typeof right === 'boolean'\n ? result !== 0n\n : fromPythonInteger(result, functionName);\n}\n// python/operator/or_ (target function module)\nfunction or_(a, b) {\n // discuss at: https://locutus.io/python/operator/or_/\n // parity verified: Python 3.12\n // original by: Kevin van Zonneveld (https://kvz.io)\n // note 1: Performs Python-style bitwise or on integer-like values.\n // example 1: or_(4, 1)\n // returns 1: 5\n // example 2: or_(true, false)\n // returns 2: true\n return pythonBitOr(a, b, 'or_');\n}" const __locutus_standalone_js_code = "// python/_helpers/_operator (Locutus helper dependency)\nfunction toPythonInteger(value, functionName) {\n if (typeof value === 'boolean') {\n return value ? 1n : 0n;\n }\n if (typeof value === 'bigint') {\n return value;\n }\n if (typeof value === 'number' && Number.isFinite(value) && Number.isSafeInteger(value)) {\n return BigInt(value);\n }\n throw new TypeError(`${functionName}() expected an integer value`);\n}\nfunction fromPythonInteger(value, functionName) {\n const numericValue = Number(value);\n if (!Number.isSafeInteger(numericValue)) {\n throw new RangeError(`${functionName}() result does not fit within JS safe integer precision`);\n }\n return numericValue;\n}\nfunction pythonBitOr(left, right, functionName) {\n const leftInt = toPythonInteger(left, functionName);\n const rightInt = toPythonInteger(right, functionName);\n const result = leftInt | rightInt;\n return typeof left === 'boolean' && typeof right === 'boolean'\n ? result !== 0n\n : fromPythonInteger(result, functionName);\n}\n// python/operator/or_ (target function module)\nfunction or_(a, b) {\n // discuss at: https://locutus.io/python/operator/or_/\n // parity verified: Python 3.12\n // original by: Kevin van Zonneveld (https://kvz.io)\n // note 1: Performs Python-style bitwise or on integer-like values.\n // example 1: or_(4, 1)\n // returns 1: 5\n // example 2: or_(true, false)\n // returns 2: true\n return pythonBitOr(a, b, 'or_');\n}" const __locutus_eval_function = (compiledCode: string): ((...args: unknown[]) => unknown) => { const evaluator = new Function('require', compiledCode + '\nreturn ' + __locutus_func_name + ';') return evaluator(__locutus_source_require) as (...args: unknown[]) => unknown } const __locutus_eval_module_export = (compiledCode: string, exportName: string): ((...args: unknown[]) => unknown) => { const module = { exports: {} as { [key: string]: unknown } } const exports = module.exports const evaluator = new Function('exports', 'module', 'require', compiledCode) evaluator(exports, module, __locutus_source_require) return module.exports[exportName] as (...args: unknown[]) => unknown } const __locutus_module_js_fn = __locutus_eval_module_export(__locutus_module_js_code, __locutus_func_name) const __locutus_standalone_ts_fn = __locutus_eval_function(__locutus_standalone_ts_code) const __locutus_standalone_js_fn = __locutus_eval_function(__locutus_standalone_js_code) describe('src/python/operator/or_.ts (tested in test/generated/python/operator/or_.vitest.ts)', function () { it('should pass example 1', function () { const expected = 5 const __locutus_variants: Array<{ name: string; fn: (...args: unknown[]) => unknown }> = [ { name: "source", fn: __locutus_source_fn }, { name: "module-js", fn: __locutus_module_js_fn }, { name: "standalone-ts", fn: __locutus_standalone_ts_fn }, { name: "standalone-js", fn: __locutus_standalone_js_fn }, ] const __locutus_run_example = (or_: typeof __locutus_source_fn) => { return or_(4, 1) } for (const __locutus_variant of __locutus_variants) { const result = __locutus_run_example(__locutus_variant.fn as typeof __locutus_source_fn) expect(result).toEqual(expected) } }) it('should pass example 2', function () { const expected = true const __locutus_variants: Array<{ name: string; fn: (...args: unknown[]) => unknown }> = [ { name: "source", fn: __locutus_source_fn }, { name: "module-js", fn: __locutus_module_js_fn }, { name: "standalone-ts", fn: __locutus_standalone_ts_fn }, { name: "standalone-js", fn: __locutus_standalone_js_fn }, ] const __locutus_run_example = (or_: typeof __locutus_source_fn) => { return or_(true, false) } for (const __locutus_variant of __locutus_variants) { const result = __locutus_run_example(__locutus_variant.fn as typeof __locutus_source_fn) expect(result).toEqual(expected) } }) })