PHPackages                             lhsazevedo/sh4objtest - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. lhsazevedo/sh4objtest

ActiveLibrary[Testing &amp; Quality](/categories/testing)

lhsazevedo/sh4objtest
=====================

v0.1.18(9mo ago)23352[6 issues](https://github.com/lhsazevedo/sh4objtest/issues)PHPPHP ^8.3CI passing

Since Apr 25Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/lhsazevedo/sh4objtest)[ Packagist](https://packagist.org/packages/lhsazevedo/sh4objtest)[ RSS](/packages/lhsazevedo-sh4objtest/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (21)Used By (0)

Hitachi SH4 Object Tester
=========================

[](#hitachi-sh4-object-tester)

The Hitachi SH4 Object Tester is a specialized simulator and testing framework developed to support the [Tokyo Bus Guide decompilation project](https://github.com/lhsazevedo/tokyo-bus-guide-decomp). This tool enables developers to run and validate SH4 object files using a suite of predefined expectations and test cases.

Note

This project is in active development and may contain breaking changes.

Features
--------

[](#features)

- Simulates Hitachi SH4 object code execution
- Provides a framework for writing and running test cases
- Supports memory allocation and initialization
- Allows mocking of function calls and return values
- Enables verification of memory writes and function calls

Usage
-----

[](#usage)

To use the Hitachi SH4 Object Tester, you need to write test cases that define the initial state, expected behavior, and assertions for your SH4 object code. Let's say that we want to test the following function:

```
void functionUnderTest(int* ptr) {
    int value = *ptr;
    int result = someFunction(value);
    *ptr = result;
}
```

This C function reads a value from the memory location pointed to by `ptr`, calls `someFunction`with that value, and then writes the result back to the same memory location.

Here's a basic example of how to structure a test case for this function:

```
# example_test.php

use Lhsazevedo\Sh4ObjTest\TestCase;

return new class extends TestCase {
    public function test_exampleFunction() {
        // Set up initial memory state
        $someAddress = $this->alloc(4);
        $this->initUint32($someAddress, 0x1234);

        // Define expected function calls
        $this->shouldCall('_someFunction')
            ->with(0x1234)
            ->andReturn(0x5678);

        // Define expected memory writes
        $this->shouldWrite($someAddress, 0x5678);

        // Run the function under test
        $this->call('_functionUnderTest')
            ->with($someAddress)
            ->run();
    }
};
```

This example demonstrates how to:

1. Allocate and initialize memory
2. Set expectations for function calls
3. Set expectations for memory writes
4. Run the function under test

Note that all expectations are defined before calling `run()`. There are no assertions after the function execution.

To run the test case, you need to execute the following command:

```
sh4objtest example_test.php path/to/your/object/file.o
```

Sh4objtest will load the object file, execute the test case, and report the results:

```
test_exampleFunction...
✔ Fulfilled: Called _someFunction
✔ Fulfilled: Wrote 0x5678 to 0x800000

[ PASS ] 2 expectations fulfilled
```

Documentation
-------------

[](#documentation)

Comprehensive documentation for this project is still in development. In the meantime, please refer to the test cases in the [Tokyo Bus Guide decompilation project](https://github.com/lhsazevedo/tokyo-bus-guide-decomp/tree/main/tests) for practical examples of how to write tests using this framework.

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance42

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~24 days

Recently: every ~43 days

Total

19

Last Release

272d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/011e68c7a2cf863af3a150252c213425d2cc638eec08afc51280bdfddf51732b?d=identicon)[lhs\_azevedo](/maintainers/lhs_azevedo)

---

Top Contributors

[![lhsazevedo](https://avatars.githubusercontent.com/u/7695608?v=4)](https://github.com/lhsazevedo "lhsazevedo (161 commits)")[![elliotwutingfeng](https://avatars.githubusercontent.com/u/30223404?v=4)](https://github.com/elliotwutingfeng "elliotwutingfeng (1 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lhsazevedo-sh4objtest/health.svg)

```
[![Health](https://phpackages.com/badges/lhsazevedo-sh4objtest/health.svg)](https://phpackages.com/packages/lhsazevedo-sh4objtest)
```

###  Alternatives

[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M1.9k](/packages/behat-behat)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[phan/phan

A static analyzer for PHP

5.6k11.2M1.1k](/packages/phan-phan)[brianium/paratest

Parallel testing for PHP

2.5k118.8M753](/packages/brianium-paratest)[maglnet/composer-require-checker

CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package

99810.9M670](/packages/maglnet-composer-require-checker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
