Hi! My name is Eduardo Ochs - this person
here - and this video is about a library
that is being developed using test
blocks,
and that is very easy to test
using test blocks.
All the most important information about
this package is in this page here.
Let me show it in the browser.
And note that this paragraph says that
pict2e-lua is an uninteresting
library that has been developed in an
interesting way - with test blocks. And
this is what we're going to see: how I'm
developing it, and how it can be tested
very easily.
Note that this page has a block that
says: Try it!
It says that we need to to run these
two eepitch blocks here.
This page has lots of links, so, for
example, if you click here you get the
definition of what is an eepitch block.
What we have to do is to copy this
thing here to a buffer. I'm going to copy
it to a temporary buffer -
but i'm going to need a smaller font -
so, here:
these bullets here are equivalent to
the red stars.
And so... let me execute these eepitch
block remember that when i execute a
line that starts with a
red star with f8
the rest of the line after the red star
is
treated as Lisp, and executed as Lisp.
This is usually used
to set up something -
usually
used to set up a target buffer
so
these things here set up a target buffer
running a shell.
These two lines here make sure that I
have the debian packages that I need.
This setenv does something weird that
I'm going to explain later, but all the
rest is standard.
So
here I'm going to
clone this github repository
and then
the shell treats all these things as
comment comments but we can treat them
as
sexps that can be executed
and this one here
shows the contents of the directory
/tmp/pict2e-lua and we can
see that it has some
screenshots,
READMEs, some .tex files, and so on,
and this weird thing here ,that is a copy
of my init file for lua
that i'm mainly going to use
because
the library that that we're going to
test
uses some pretty-printing
functions that are defined here.
So this
expression here
tells lua to read the init file from
this temporary directory here.
We need this sexp here. It defines
lots of functions, including this one
here: find-pict2elua
so now this function is defined and we
can open these .lua files and run the
tests in them.
Here is one of these files. You can see
here a kind of index of the file and you
can see that some of these links here
point to tests -
for example if we follow this link here
we go to a test block, and we can execute
this test block with
a series of f8s.
Note that the f8s create a target buffer
running Lua, here
so they create several data structures
and they print these data structures in
several ways.
There's
one thing that is very tricky and this
page with details explains it -
hopefully explains it
well.
The thing is that
in some of the tests we need to show the
pdf file,
and we need to run and Emacs command that is
going to split the screen in this way,
and show the pdf file in this lower
right window -
and the command that does that is this
(etv) here so we have to define it in the
right way -
and the trick is that this header here
contains
two blocks of
one liners
this is the first one and this is the
second one
and we need to execute all the sexps in
the second one
I'm going to execute them with M-7
M-e, that is equivalent to
M-e .
So: all done -
so now hopefully this function here is
defined in the right way.
And let me execute the last test in the
this file that that calls this function
(etv)
so the first part of the test is very
easy
nothing special - it just sends comments
to Lua - but then we have this line here
that calls a class called Show,
and this class saves
some TeX code to a .tex file and run
latex to compile that and to generate a
pdf
and this is a bit tricky - and the
important thing is that this
takes several seconds to run and we need
to wait these several seconds.
So: if I send this this line here to the
Lua REPL
you can see that it takes a few seconds -
until it says blah blah Success!!! and now
we can run this (etv) here
and it shows a drawing here with the
with the bounding box in yellow.
In this file here the drawings are
not very interesting -
this is just the core of my library - so
let me show how to
generate this drawing here that
I'm using in the
screenshots - this one.
This defun here defines the function `a'
as a function that opens the first Lua
file - with the core definitions - and `b'
defines b is the function that opens the
second Lua file
with some extra classes and some
stranger drawings.
So
let's execute `b'.
We are in the second file here
and let's execute this test here
uh - sorry
this one: Plot2D-test2.
So here we have
a test block -
it's quite big - it defines...
it changes the preamble,
it defines several functions, it uses
some
classes that are defined in this file,
and so on...
and then after printing the TeX code
it has this line here that contains a
show
if I execute to this line it takes a few
seconds... it says Success!!! and now we can
show the .pdf.
And: ta-da!
this is the figure that I wanted to show.
So, that's it.
Again:
this is a
library that is not interesting in
itself, but
i think that the way in which it can be
tested - which is very similar to the way
in which I'm developing it
is interesting in itself - so
if you are interested in test blocks
please test this,
and send feedback. That's it! bye =)