The Monty Python test

The Monty Python test

Have the output of a test run.

memory={-6, -14, -1, -1, -1, -1, -1, -1, -1, -1, -1}
size=11
Size=8
Buffer size=3
memory={-1, -1, -1, -1, -1, -1, -1, -1}
buffer memory={-6, -14, -1}

I made a new port—INNER_BOARD

It’s “board,” as in, “clipboard. It uses the inner head, and either cuts numbers out of the memory array when sent a negative number, or inserts them into the memory array when a positive number is sent. This changes the size of the memory array.

In the above test, I wrote a figure that cuts out the first three numbers from the top of memory. That’s why the program ended with all those -1/s—I wanted it to stop gracefully. Come to think of it, I should make sure it doesn’t cause a runtime error if those aren’t there. Brb.

SHIT!

I’m going to have to hunt down the problem and fix it. I’ve no clue how long this is going to take.

As bug hunts go, that was quick and painless.

It turned out that it was the test code, calling buffer.length when the buffer array hadn’t been created. That gave me a null pointer, and computer no likey.

To fix it, I created an empty array of length 0 in the constructor of Figure. The rest of the code is already all kinds of safe, I did a lot of work to make it so, but when I get to logging what’s happening with the full system, outside programs could attempt to call memory or buffer before any operations take place. Best to have arrays there, even if they have nothing in them.

Next, we have what I call “the Monty Python test.”

Here’s the output.

memory={-8, -12, 3, -6, -12, 6, -5, -14, -1, -1, -1, -1, 1, 2, 3, 4, 5}
size=17
Size=15
Buffer size=2
memory={-8, -12, 3, -6, -12, 6, -5, -14, -1, -1, -1, -1, 1, 2, 5}
buffer memory={3, 4}

I’ve also added ports that give the inner head’s address in positive and negative form.

That’s about as much as I can do without putting figures in some world. I’m calling it “Realm.” Today’s goal is to get the Monty Python test to run correctly from within the realm.

Yep, it’s the holy hand grenade for you, sucker.

There it is, nice and easy.

So far, it’s an array of Figures, and a method to add a Figure to that array. The add method gives the Figure a name, a pointer to the Realm, and tells it what address it’s living at.

The important part of the test output you’re about to see is the first few lines. I just made sure that the fields that need to be updated are getting updated. Then I just called run by using the right index in the array of Figures. I named that array “population,”

realm.population[index].run();

Here’s the output and I’m out.

Before adding, name=2048, address=0, realm=null.
After adding, name=0, address=2, realm=Realm@1c8697ce.
memory={-8, -12, 3, -6, -12, 6, -5, -14, -1, -1, -1, -1, 1, 2, 3, 4, 5}
size=17
Size=15
Buffer size=2
memory={-8, -12, 3, -6, -12, 6, -5, -14, -1, -1, -1, -1, 1, 2, 5}
buffer memory={3, 4}

Comments are closed.