Log In  
Follow
elgopher

Small numbers (such as 0.00001) are not sent properly between processes. For example, when process A sends 0.00001 to process B, the process B receives 1.

Instructions how to reproduce:

  • load #wuguzudofo and run
  • hit "z" to create child process and send small number from this process to the parent
  • parent process will present 1 instead of 0.00001
1
0 comments



Unitron is a testing framework for Picotron. With unitron you can write unit tests and run them directly in Picotron.

More information: https://github.com/elgopher/unitron

The cart is work in progress, but you can test it today by downloading cart from Github.

Current state of the project:

  • API for writing tests (assert_xxx functions) is defined and is working fine
  • Test runner is also working fine, but has serveral limitations
    • folding tests in test tree not implemented
    • no horizontal scrolling of console messages
    • rather boring UI (for now ;) )
  • Minimal documentation

Here is some demo:

Your feedback is greatly appreciated :)

5
6 comments



Cart #require-0 | 2024-03-17 | Embed ▽ | License: CC4-BY-NC-SA
16

I wrote Lua require function based on the include function found in /system/lib/head.lua:791.

This function loads Lua modules similar to standard require found in Lua:

  • it loads the file
  • executes the file
  • returns the module returned by included file
  • caches the module, so next call to require will return already loaded module

How to use:

  • put the source code of require function in your main.lua:
function require(name)
   if _modules == nil then
   		_modules={}
   	end

	local already_imported = _modules[name]
	if already_imported ~= nil then
		return already_imported
	end

	local filename = fullpath(name..'.lua')
	local src = fetch(filename)	

	if (type(src) ~= "string") then 
		notify("could not include "..filename)
		stop()
		return
	end	

	-- https://www.lua.org/manual/5.4/manual.html#pdf-load
	-- chunk name (for error reporting), mode ("t" for text only -- no binary chunk loading), _ENV upvalue
	-- @ is a special character that tells debugger the string is a filename
	local func,err = load(src, "@"..filename, "t", _ENV)
	-- syntax error while loading
	if (not func) then 
		send_message(3, {event="report_error", content = "*syntax error"})
		send_message(3, {event="report_error", content = tostr(err)})

		stop()
		return
	end

	local module = func()
	_modules

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=143480#p)
16
4 comments