Moose Utils Extend

It extend test helper day here in the Moose-pen.

Yesterday I managed to get the 'Between' operator to work but there was one little thing that was bugging my and that was I had some 40 lines of new code and only three new tests for the possible exception the 'Between' operator might generate. To boot the three new tests where an anti-pattern.

Now there is no problem with having anti-patterns in test code you just end up with many more lines in your than you need and they may be problematic to fix if they ever go wrong. Normally I would not bother to re-factor just three tests but I can see myself making many more 'Exception' tests for the other operators like 'IsNull' or 'In'. Thus, in this case I will fix that.

So given the basic test;

Why Programmers Use the Test Hierarchy Antipattern

The first part of this series described Test Hierarchy, a hierarchy of test classes that mirrors the classes under test, and explained why it’s an antipattern. Part two explored what makes a good unit test and why Test Hierarchy does not. This third and final post reflects on why programmers use Test Hierarchy and why these reasons aren’t persuasive.

What is a Bool?

Perl allows pretty much any value to be evaluated in a boolean context:

if ($something) {

No matter what $something is, it will safely evaluate to either true or false. (With the exceptions of a few edge cases like blessed objects which are overloaded to throw an error when evaluated as booleans.)

So when a Moose class does something like this, what does it mean?

has something => (
   is  => 'ro',
   isa => 'Bool',

Why is parsing considered solved?

"Why is parsing considered solved?" is the newest entry on my Ocean of Awareness blog.

It is often said that parsing is a "solved problem". Given the level of frustration with the state of the art, the underuse of the very powerful technique of Language-Oriented Programming due to problematic tools, and the vast superiority of human parsing ability over computers, this requires explanation.
On what grounds would someone say that parsing is "solved"? To understand this, we need to look at the history of Parsing Theory. In fact, we'll have to start decades before computer Parsing Theory exists, with a now nearly-extinct school of linguistics, and its desire to put the field on strictly scientific basis.

More Moose Operations

Its advance my code day here in the Moose-Pen.

Seems I have hit a milestone in the Database::Accessor/Driver::DBI project I have completed all the easy stuff and I am moving over to the more complicated or at least ignored till now parts.

I decided to work on some of the more advance operators found in conditional statements namely 'Between', 'In', 'Not In', 'Like', 'Is Null' and 'Is Not Null'. Now one problem with these six operators is they are very SQLish, epically the 'Like' operator, and despite me trying to come up with a more generic set of operator names just looked too MongoDB specific. I wonder if one of the devlopers of MongoDB had the same problem to solve?

To start off I created a new test case '32_where_operators.t' that is basically a clone of '30_where_basic.t' but I stripped out all the tests and to start I will try this one;

Update to XPath Sandbox

As part of my project to create a tutorial for XML::LibXML, I created an XPath Sandbox tool that allows you to try out different XPath expressions directly in your browser. I've recently enhanced that tool to add a couple of useful features:

  • 'Upload'* your own XML files, and query them
  • Namespace support, including registering your own prefix mappings

When working with the built-in sample files, URL parameters can be used to: select a file, specify an XPath expression, override the default namespace prefix mappings. Here's an example link that does all three!

* I used the term upload in 'scare quotes' because it's a client-side app, nothing actually gets sent to the server.

The Perl Conference 2018 Newsletter: 06/02/2018

In This Issue:

Why May 2018 is so special?

As we entered the sixth month of the year 2018. So what have I achieved in May 2018? In short, plenty. Let me share the details.

May 2018 has been the best month so far in the year 2018. In this month, I submitted 60 Pull Requests. Only two occasions in the past where I had better number than May 2018. It was 77 Pull Requests in December 2016 and 63 Pull Requests in January 2017.

As of today, 2nd June 2018, I have submitted 858 Pull Requests. Of those 575 Pull Requests have been merged successfully. I am hoping to get to the magic number 1000 before the next London Perl Workshop, which is the 3rd Nov 2018. I am keeping my fingers crossed.

The Last Moose Sort

It is more order code day here in the Moose-Pen

Yesterday I left off with the choice of either a change to do to my tests or a change to my code to solve this error;

# Expected SQL-> ORDER BY people.last_name, people.first_name
# Generated SQL-> ORDER BY people.last_name ASC, people.first_name ASC
Now this comes from how how I define the 'order' attribute in the 'Database::Accessor::Roles::Element' role;

  has order => (
        is      => 'rw',
        isa     => 'SQLOrder',
        default => Database::Accessor::Constants::ASC,

Rewriting B:Deparse and Reintroducing B::DeparseTree

I will be giving a talk on B::DeparseTree and its use in a debugger Devel::Trepan at the upcoming YAPC 2018 in Glasgow. As a result, I have been completely refactoring B::DeparseTree and have a number of thoughts on it and B::Deparse.

Here are some of them. This first part focuses more about B::Deparse and how it could be (or in a sense is) being rewritten. The second part if I get around to writing it will be about the cool features of B::DeparseTree from an application.


As someone who make a lot of mistakes, I’ve long wanted to improve the precision of debugging and error reporting. Through Perlmonks, I was directed upon the idea of using the OP address as means to get more detailed information of where the program is. I was also pointed to B::Deparse.

Test Hierarchy Produces Poor Unit Tests

The first part of this series described Test Hierarchy, a hierarchy of test classes that mirrors the classes under test, and explained why it’s an antipattern. For how common it is, this practice doesn’t even produce good unit tests.

New release of Perl::Build

Perl::Build is a Perl Builder created by tokuhirom. You can build and install Perl by:

$ curl -L | perl - 5.26.2 /opt/perl-5.26/

Also, it is the backend of plenv-install:

$ git clone $(plenv root)/plugins/perl-build
$ plenv install 5.26.2

Recently I became its maintainer, and have released a new version to CPAN. The new version contains the following changes:


#66, #67, #73, #74, #75, thanks Grinnz, anttilinno, djzort, sjn.

Now Perl::Build uses to find available Perl versions and Perl tarball URLs. MetaCPAN indexer is quite fast. So, as soon as a new Perl is released, you should be able to install it by Perl::Build.

Use HTTP::Tinyish for https support

#72, thanks AnaTofuZ.

Still sorting Moosse

It take back my words day here in the Moose-Pen

I have to adjust how the SQL is produced yet again. Today I was playing about with the '60_order_by.t' tast case of Driver::DBI and had it all nicely set up and on my first run I was getting errors like this;

# Expected SQL--> INSERT INTO people ( first_name, last_name ) VALUES( ?, ? )
# Generated SQL-> INSERT INTO people ( first_name, last_name ) VALUES( ?, ? )
 ORDER BY people.last_name, people.first_name
and even this

# Expected SQL--> DELETE FROM people
# Generated SQL-> DELETE FROM people
 ORDER BY people.last_name, people.first_name
This all stems from this post

Is language just a set of strings?

The newest entry on my Ocean of Awareness blog: "Is language just a set of strings?"

"The languages human beings use with each other are powerful, varied, flexible and endlessly retargetable. The parsers we use to communicate with computers are restrictive, repetitive in form, difficult to reprogram, and prohibitively hard to retarget. Is this because humans have a preternatural language ability?
"Or is there something wrong with the way we go about talking to computers? How the Theory of Parsing literature defines the term "language" may seem of only pedantic interest. But I will argue that it is a mistake which has everything to do with the limits of modern computer languages."

A new object system for Perl

I just released Dot, it's a new object system for Perl, some of its highlight and difference:
  • There's no code for this object system, you don't even have to install the module to use it.
  • An object is a hash, a method is a closure, and a class is a subroutine.
  • True private variable, not by pretending.
  • Multiple inheritance without the diamond problem.
  • Method dispatching takes zero time, in fact it is not needed at all.
  • The built-in mechanism of Perl 5 OO is completely bypassed.
  • If you want a bird you could inherit from a jungle and remove everything else so that it's the only thing left.
  • You don't need a package to change the inheritance of an object, you only need a single statement.
  • Inheritance of a class could be chosen at runtime, the inheritance of the objects of the same class could thus be different.
  • Easy creation of metaclass, metametaclass, etc.
You can see the full documentation on CPAN .

Perl 6 Training at TPC - Salt Lake City

After TPC join me for The Hitch-Hiker's Guide to Perl 6 at The Little America in Salt Lake City.

100% Moose

Its add a little new day here in the Moose-Pen

I left off yesterday with the problem of the little build in test DB that comes with DBI not working correctly with SQL where the table names are added to the field names. So this SQL would work;

UPDATE user SET address = ? WHERE user.username = ?
but this would not

SELECT user.username FROM user WHERE user.username = ?
Now I am either faces with drooping the '10_crud_basic.t' test case which I would like to keep or changing my code to accommodate this little DB and any others that may not like table names on the fields.

Testing Insights from B::DeparseTree

rockyb’s recent post about B::DeparseTree contained several insights on testability and writing good tests. Here are my takeaways.

PAUSE Privacy Policy

Today is GDPR Day, and to celebrate that, the PAUSE admins have added a Privacy Policy to PAUSE. This tells you:

  • what personal data is processed by PAUSE;
  • what PAUSE does with that data;
  • how that data is shared (with the rest of the CPAN ecosystem);
  • PAUSE's lawful basis for holding your information (this is a GDPR term, which essentially answers the question "what gives PAUSE the right to hold your personal data?")
  • what your rights are, and how to exercise them.

The policy is linked off the sidebar in PAUSE, and the source is a markdown document in PAUSE's github repo.

Module Adoption Opportunities! YAY!

Quite some time back I was anxious to find a Perl module or two to work on and gain some experience in the process of releasing modules to the CPAN. Like I'm sure many of you do, I looked through the ADOPTME list to see what looked simple and or fun to work on.

WWW::Shorten and friends came on my radar and I started there. I reached out to the authors of many modules in the WWW::Shorten to see if they wouldn't mind joining me in the effort to bring them all to a similar point. I seem to recall everyone being happy and eager to work together, so this part went well. We created a GitHub organization to house the various modules.

Inevitably, though, I began working on other things and unfortunately have let WWW::Shorten and friends languish. This, however, opens the opportunity for you to take on the task of maintaining a family of modules and bring their test coverage up to date and add in modules for the new shortening services that are available now.

Please let me know if you're interested and I'll happily pass off some commit and PAUSE permissions!

About is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is hosted by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.