Compare commits
5 Commits
f63a48809e
...
137da7bee1
Author | SHA1 | Date | |
---|---|---|---|
137da7bee1 | |||
a8315c39d5 | |||
7d7bf5c197 | |||
cdbb85c692 | |||
a63566cdad |
|
@ -1,8 +1,29 @@
|
||||||
|
# WARNING!
|
||||||
|
# THIS IS AN AUTOGENERATED FILE!
|
||||||
|
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
||||||
|
|
||||||
name: LÖVE/Lua Library
|
name: LÖVE/Lua Library
|
||||||
on: [push]
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md']
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Test:
|
Lua-Testing:
|
||||||
uses: jmaa/workflows/.gitea/workflows/lua-testing.yaml@v6.21
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Lua
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y luajit
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Run testing library
|
||||||
|
run: luajit test/init.lua
|
||||||
Static-Analysis:
|
Static-Analysis:
|
||||||
uses: jmaa/workflows/.gitea/workflows/lua-static-analysis.yaml@v6.21
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Luacheck linter
|
||||||
|
uses: https://github.com/lunarmodules/luacheck@v1.1.1
|
||||||
|
|
21
.gitignore
vendored
21
.gitignore
vendored
|
@ -1,2 +1,19 @@
|
||||||
# Ignore editor files
|
# WARNING!
|
||||||
.*.swp
|
# THIS IS AN AUTOGENERATED FILE!
|
||||||
|
# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
||||||
|
|
||||||
|
# Löve: Exclude build items
|
||||||
|
/bin/
|
||||||
|
/lib/
|
||||||
|
.love-cache/
|
||||||
|
|
||||||
|
# Compiled Lua sources
|
||||||
|
luac.out
|
||||||
|
|
||||||
|
# Misc (Image, MacOS, Backups) files
|
||||||
|
*.psd
|
||||||
|
*~
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Tools
|
||||||
|
*.tiled-session
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
-- WARNING!
|
||||||
|
-- THIS IS AN AUTOGENERATED FILE!
|
||||||
|
-- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
||||||
|
|
||||||
std = "love+max"
|
std = "love+max"
|
||||||
cache = true
|
cache = true
|
||||||
include_files = {"**.lua", "*.luacheckrc"}
|
include_files = {"**.lua", "*.luacheckrc"}
|
||||||
|
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2017-2025 Jon Michael Aanes
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
61
README.md
61
README.md
|
@ -1,22 +1,32 @@
|
||||||
|
<!-- WARNING! -->
|
||||||
|
<!-- THIS IS AN AUTOGENERATED FILE! -->
|
||||||
|
<!-- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN! -->
|
||||||
|
|
||||||
# Assert Gooder
|
# Assert Gooder
|
||||||
|
|
||||||
_Lua_ library implementing an alternative version of Lua's `assert` function,
|
Supercharged assert replacement.
|
||||||
giving much better error messages, when asserts fails. It does this by analysing
|
|
||||||
the body of the assert, and figuring out what the failing assert call is
|
Lua Library that replaces the default [assert](https://www.lua.org/manual/5.4/manual.html#pdf-assert) function with one that can
|
||||||
attempting to test against.
|
emit improved error messages. The improved assert function parses the
|
||||||
|
assert condition, inspects the state of the program and emits an improved
|
||||||
|
error message.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
function f (a)
|
function f (a)
|
||||||
|
|
||||||
|
```
|
||||||
assert(type(a) == 'string')
|
assert(type(a) == 'string')
|
||||||
|
```
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
f(42)
|
f(42)
|
||||||
```
|
```
|
||||||
|
|
||||||
Without `assert-gooder`, the above code would fail with the error message
|
Without [assert-gooder](index.html#), the above code would fail with the error message
|
||||||
`assertion failed!`. With `assert-gooder`, it will fail with this error message:
|
`assertion failed!`. With [assert-gooder](index.html#), it will fail with this error message:
|
||||||
`assertion failed! bad argument #1 'a' to 'f' (string expected, but got number: 42)`,
|
`assertion failed! bad argument #1 'a' to 'f' (string expected, but got number: 42)`,
|
||||||
|
|
||||||
## Motivation
|
## Motivation
|
||||||
|
@ -34,13 +44,42 @@ even more helpful messages.
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
Download, and use `assert = require "assert-gooder"` to overwrite Lua's default
|
Download, and use `assert = require "assert-gooder"` to overwrite Lua's default
|
||||||
assert with `assert-gooder`.
|
assert with [assert-gooder](index.html#).
|
||||||
|
|
||||||
|
- Author: Jon Michael Aanes (jonjmaa@gmail.com)
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
This project requires [PUC Lua 5.1](https://www.tecgraf.puc-rio.br/lua/mirror/versions.html#5.1) or [LuaJIT](https://luajit.org/luajit.html). Newer versions of PUC Lua are not supported.
|
||||||
|
|
||||||
|
This project does not have any library requirements 😎
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Feel free to submit pull requests. Please follow the [Code Conventions](CONVENTIONS.md) when doing so.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
```
|
```
|
||||||
"THE BEER-WARE LICENSE" (Revision 42):
|
MIT License
|
||||||
<jonjmaa@gmail.com> wrote this library. As long as you retain this notice you
|
|
||||||
can do whatever you want with this stuff. If we meet some day, and you think
|
Copyright (c) 2017-2025 Jon Michael Aanes
|
||||||
this stuff is worth it, you can buy me a beer in return.
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,3 +1,47 @@
|
||||||
|
--- # Assert Gooder
|
||||||
|
--
|
||||||
|
-- Supercharged assert replacement.
|
||||||
|
--
|
||||||
|
-- Lua Library that replaces the default `assert` function with one that can
|
||||||
|
-- emit improved error messages. The improved assert function parses the
|
||||||
|
-- assert condition, inspects the state of the program and emits an improved
|
||||||
|
-- error message.
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- ## Example
|
||||||
|
--
|
||||||
|
-- ```lua
|
||||||
|
-- function f (a)
|
||||||
|
-- assert(type(a) == 'string')
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- f(42)
|
||||||
|
-- ```
|
||||||
|
--
|
||||||
|
-- Without `assert-gooder`, the above code would fail with the error message
|
||||||
|
-- `assertion failed!`. With `assert-gooder`, it will fail with this error message:
|
||||||
|
-- `assertion failed! bad argument #1 'a' to 'f' (string expected, but got number: 42)`,
|
||||||
|
--
|
||||||
|
-- ## Motivation
|
||||||
|
--
|
||||||
|
-- Assertions are useful to ensure internal consistency, when you're writing code
|
||||||
|
-- in a hurry, but in Lua (and most other languages), these assert constructs never
|
||||||
|
-- produce useful error messages, but rather unhelpful `assert failed!` errors and
|
||||||
|
-- a stack trace.
|
||||||
|
--
|
||||||
|
-- By making it a runtime library, instead of a "compile-time" rewrite, we gain
|
||||||
|
-- flexibility. It's much easier to import a library, than restructuring then
|
||||||
|
-- compile pipeline. It also means that we have access to runtime values, allowing
|
||||||
|
-- even more helpful messages.
|
||||||
|
--
|
||||||
|
-- ## Setup
|
||||||
|
--
|
||||||
|
-- Download, and use `assert = require "assert-gooder"` to overwrite Lua's default
|
||||||
|
-- assert with `assert-gooder`.
|
||||||
|
--
|
||||||
|
-- @author Jon Michael Aanes (jonjmaa@gmail.com)
|
||||||
|
|
||||||
|
local _VERSION = '0.5.3'
|
||||||
|
|
||||||
local lexer = assert(require((... and select('1', ...):match('.+%.') or '')..'lua_lang'), '[assert-gooder]: Could not load vital library: lua_lang')
|
local lexer = assert(require((... and select('1', ...):match('.+%.') or '')..'lua_lang'), '[assert-gooder]: Could not load vital library: lua_lang')
|
||||||
local shunting_yard = assert(require((... and select('1', ...):match('.+%.') or '')..'Parser'), '[assert-gooder]: Could not load vital library: Parser')
|
local shunting_yard = assert(require((... and select('1', ...):match('.+%.') or '')..'Parser'), '[assert-gooder]: Could not load vital library: Parser')
|
||||||
|
@ -764,4 +808,3 @@ return function (condition, format, ...)
|
||||||
-- Throw error message
|
-- Throw error message
|
||||||
error(table.concat(l, ''), 2)
|
error(table.concat(l, ''), 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
9
init.lua
9
init.lua
|
@ -1,5 +1,6 @@
|
||||||
local _VERSION = '0.5.2'
|
-- WARNING!
|
||||||
|
-- THIS IS AN AUTOGENERATED FILE!
|
||||||
|
-- MANUAL CHANGES CAN AND WILL BE OVERWRITTEN!
|
||||||
|
|
||||||
local assert_gooder = assert(require((... and select('1', ...):match('.+')..'.' or '')..'assert-gooder'), '[assert-gooder]: Could not load vital library: assert-gooder')
|
-- This file automatically redirects to "assert-gooder.lua"
|
||||||
assert_gooder._VERSION = _VERSION
|
return require (((...) ~= 'init' and (...) .. '.' or '') .. 'assert-gooder')
|
||||||
return assert_gooder
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user