-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from mockagne/bugfix/3-Lua_5.3_compatibiliy_wit…
…h_unpack #3: Lua 5.3 fix for unpack()
- Loading branch information
Showing
15 changed files
with
496 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<buildpath> | ||
<buildpathentry kind="src" path="test"/> | ||
<buildpathentry kind="src" path="src"/> | ||
<buildpathentry kind="con" path="org.eclipse.ldt.ExecutionEnvironmentContainer/lua/5.1"/> | ||
</buildpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>mockagne</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.dltk.core.scriptbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.ldt.nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Grammar__default_id=lua-5.1 | ||
eclipse.preferences.version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
dist: focal | ||
|
||
language: c | ||
|
||
sudo: required | ||
|
||
os: linux | ||
|
||
env: | ||
- LUA_VERSION=5.1 | ||
- LUA_VERSION=5.2 | ||
- LUA_VERSION=5.3 | ||
|
||
before_script: | ||
- sudo apt-get -y install lua$LUA_VERSION | ||
- sudo apt-get -y install liblua$LUA_VERSION-dev | ||
- sudo apt-get -y install luarocks | ||
- sudo luarocks install busted | ||
|
||
script: | ||
- sudo luarocks make | ||
- busted test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,39 @@ | ||
mockagne | ||
======== | ||
# mockagne - Mocking Framework for Lua | ||
|
||
Fully dynamic mocking for Lua. Create mock objects with ease, teach them to return values and verify their invocations. | ||
`mockagne` is a fully dynamic mocking framework that is designed to be a Lua variant of the famous Java framework [mockito](https://site.mockito.org/). | ||
|
||
## Usage | ||
### Creating and using mocks | ||
Start by requiring mockagne and creating some local function references for better readability: | ||
## In a Nutshell | ||
|
||
```lua | ||
local mockagne = require "mockagne" | ||
|
||
local when = mockagne.when | ||
local any = mockagne.any | ||
local verify = mockagne.verify | ||
``` | ||
|
||
Then just create a mock instance for you: | ||
|
||
```lua | ||
t = mockagne.getMock() | ||
local mockagne = require("mockagne") | ||
local mock = mockagne.getMock() | ||
mockagne.when(mock.say(mockagne.any())).thenAnswer("Hello world") | ||
-- ... | ||
mock.ask("You name?") | ||
mockagne.verify(mock.ask("You name?")) | ||
``` | ||
|
||
Then you can invoke anything on the mock instance. Like: | ||
## Information for Users | ||
|
||
```lua | ||
t.foo() | ||
``` | ||
|
||
### Verifying calls to mocks | ||
After your test has executed, you might be interested if a specific function on a mock was called. For example, to check if function `foo()` was call, you would simply say: | ||
|
||
```lua | ||
verify(t.foo()) | ||
``` | ||
|
||
Same works with parameters: | ||
|
||
```lua | ||
t.foo("bar") | ||
verify(t.foo("bar")) | ||
``` | ||
|
||
### Returning values from mocks | ||
If you want a call to `t.foo()` to return a value, you can teach the mock with: | ||
|
||
```lua | ||
when(t.foo("bar")).thenAnswer("baz") | ||
print(t.foo("bar")) -- this will print "baz" | ||
``` | ||
* [User Guide](doc/user_guide/user_guide.md) | ||
|
||
Otherwise calls to mock methods will return `nil`. | ||
## Dependencies | ||
|
||
### More examples | ||
For more examples, refer to [`mockagne_spec.lua`](spec/mockagne_spec.lua) that comes with. It contains all unit tests used to exercise mockagnes all features. | ||
### Runtime Dependencies | ||
|
||
## Installation | ||
`mockagne` is a single-file pure-Lua module with no other runtime dependencies than Lua 5.1 or later. | ||
|
||
Easiest way to install `mockagne` is through `luarocks`. Just run | ||
### Test Dependencies | ||
|
||
luarocks install mockagne | ||
| Dependency | Purpose | License | | ||
|------------------------------------------|--------------------------------------------------------|-------------------------------| | ||
| [busted][busted] | Unit testing framework | MIT License | | ||
|
||
For manual installation, just add `mockagne.lua` to your `package.path`. | ||
[busted]: https://github.com/Olivine-Labs/busted | ||
|
||
## More information | ||
### License | ||
|
||
_Mockagne_ was originally written by Janne Sinivirta and Marko Pukari. It was created to help with testing of our mobile games written in Lua. It is now maintained by | ||
Sebastian Bär. | ||
Lua is Open Source, distributed under the terms of the [MIT license](License). | ||
|
||
_Mockagne_ name is a cross between _mock_ and _champagne_, like it's Java big brother _mockito_. We are great fans of _mockito_ and mockagne is heavily based on _mockito_'s DSL. | ||
Copyright (c) 2013 Punch Wolf Game Studios. | ||
Copyright (c) 2020 [Exasol](https://www.exasol.com). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changes | ||
|
||
* [1.0.2](changes_1.0.2) | ||
* [1.0.1](changes_1.0.1) | ||
* [1.0.0](changes_1.0.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# mockange 1.0.0, released 2013-07-13 | ||
|
||
Code name: First Release | ||
|
||
## Features | ||
|
||
* Added basic mocking | ||
|
||
## Documentation | ||
|
||
* Added basic user guide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# mockagne 1.0.1, released 2013-07-13 | ||
|
||
Code name: Support for `nil` primitive fields | ||
|
||
## Features | ||
|
||
* Added support | ||
|
||
## Documentation | ||
|
||
* Improved user guide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# mockagne 1.0.2, released 2020-09-03 | ||
|
||
Code name: Resurrection | ||
|
||
## Summary | ||
|
||
After an extended break starting 2013, with this release `mockagne` is now maintained again. | ||
We added compatibility for Lua 5.3, improved the project structure and added CI builds. | ||
|
||
## Bug Fixes | ||
|
||
* #3: Fixed Lua 5.3 incompatibility caused by global `unpack()` | ||
|
||
## Documentation | ||
|
||
* #3: Added change log, restructured documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# User Guid — `mockagne` | ||
|
||
## Introduction | ||
|
||
_Mockagne_ was originally written by Janne Sinivirta and Marko Pukari. It was created to help with testing of our mobile games written in Lua. It is now maintained by Sebastian Bär. | ||
|
||
_Mockagne_ name is a cross between _mock_ and _champagne_, like it's Java big brother _mockito_. We are great fans of _mockito_ and mockagne is heavily based on _mockito_'s DSL. | ||
|
||
## Using `mockagne` | ||
|
||
### Creating and using mocks | ||
Start by requiring mockagne and creating some local function references for better readability: | ||
|
||
```lua | ||
local mockagne = require "mockagne" | ||
|
||
local when = mockagne.when | ||
local any = mockagne.any | ||
local verify = mockagne.verify | ||
``` | ||
|
||
Then just create a mock instance for you: | ||
|
||
```lua | ||
t = mockagne.getMock() | ||
``` | ||
|
||
Then you can invoke anything on the mock instance. Like: | ||
|
||
```lua | ||
t.foo() | ||
``` | ||
|
||
### Verifying calls to mocks | ||
After your test has executed, you might be interested if a specific function on a mock was called. For example, to check if function `foo()` was call, you would simply say: | ||
|
||
```lua | ||
verify(t.foo()) | ||
``` | ||
|
||
Same works with parameters: | ||
|
||
```lua | ||
t.foo("bar") | ||
verify(t.foo("bar")) | ||
``` | ||
|
||
### Returning values from mocks | ||
If you want a call to `t.foo()` to return a value, you can teach the mock with: | ||
|
||
```lua | ||
when(t.foo("bar")).thenAnswer("baz") | ||
print(t.foo("bar")) -- this will print "baz" | ||
``` | ||
|
||
Otherwise calls to mock methods will return `nil`. | ||
|
||
### More examples | ||
For more examples, refer to [`mockagne_spec.lua`](spec/mockagne_spec.lua) that comes with. It contains all unit tests used to exercise mockagnes all features. | ||
|
||
## Installation | ||
|
||
Easiest way to install `mockagne` is through `luarocks`. Just run | ||
|
||
luarocks install mockagne | ||
|
||
For manual installation, just add `mockagne.lua` to your `package.path`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
package = "Mockagne" | ||
version = "1.0-2" | ||
|
||
source = { | ||
url = "https://github.com/PunchWolf/mockagne/releases/download/v.1.0.2/mockagne-1.0.tar.gz", | ||
dir = "mockagne-1.0" | ||
url = "https://github.com/PunchWolf/mockagne", | ||
tag = "1.0.2" | ||
} | ||
|
||
description = { | ||
summary = "Fully dynamic mocking for Lua.", | ||
detailed = [[ | ||
Fully dynamic mocking for Lua. Create mock objects with ease, | ||
teach them to return values and verify their invocations. | ||
]], | ||
homepage = "https://github.com/PunchWolf/mockagne", | ||
homepage = "https://github.com/mockagne/mockagne", | ||
license = "MIT" | ||
} | ||
dependencies = { | ||
"lua >= 5.1" | ||
} | ||
|
||
dependencies = { "lua >= 5.1, <= 5.4" } | ||
build = { | ||
type = "builtin", | ||
modules = { | ||
mockagne = "mockagne.lua" | ||
} | ||
modules = {mockagne = "src/mockagne.lua"}, | ||
copy_directories = { "doc", "test" } | ||
} |
Oops, something went wrong.