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.19(1mo ago)23432[6 issues](https://github.com/lhsazevedo/sh4objtest/issues)PHPPHP ^8.3CI passing

Since Apr 25Pushed 2w ago1 watchersCompare

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

READMEChangelog (10)Dependencies (6)Versions (22)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

42

—

FairBetter than 88% of packages

Maintenance74

Regular maintenance activity

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

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 ~38 days

Recently: every ~106 days

Total

20

Last Release

40d 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 (162 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

[laravel/framework

The Laravel Framework.

34.8k543.8M19.9k](/packages/laravel-framework)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k101.8M2.2k](/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.2k28.9M2.3k](/packages/infection-infection)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)

PHPackages © 2026

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