Extension:Expect/nn

Category:GPL licensed extensions/nn
MediaWiki extensions manual
Expect
Release status: betaCategory:Beta status extensions/nn
Implementation API Category:API extensions/nn
Description Tilbyr utvida assertions i Scribunto.
Author(s)
Latest version 0.1.0
Compatibility policy Master maintains backward compatibility.
MediaWiki >= 1.33
Database changes No
License GNU General Public License 2.0 or later
Download Category:Extensions in GitHub version control/nn
README, LDoc
Translate the Expect extension
Category:All extensions/nn

Expect tilbyr eit utvida rammeverk for assertions.

Det er basert på beregningsgrafer som er ferdiglagd før de vert brukt for omfattande kontrollar.

Installering

Expect er avhengig av modular frå Scribunto-utvidinga.

  • Download and place the file(s) in a directory called Expect in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'Expect' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Bruk

Arbeidsflyten er å definera ein graf, og deretter gje argument til grafen. Definisjonen er gjord ein gong, men grafen kan brukast på nytt fleire gonger.

-- Load the lib
local expect = require 'expect'

-- Create a few compute graphs
local expectString = expect:create():asType():toBeEqual( 'string' )
local expectNoColon = expect:create():toBeUMatch( '^[^:]*$' )

-- Create an exported hash
local p = {}

-- Add a function
function p.helloWorld( name )
	-- Call the compute graphs
	expectString( name )
	expectNoColon( name )

	-- Should be safe to do whatever now
	return mw.ustring.format( 'Hi there %s!', name )
end

-- Return the exported hash
return p

For meir hjelp, sjå den genererte LDoc dokumentasjonen.

Utvikling

For å attskape det Vagrant-baserte utviklingsmiljøet, sjå Expect: Topics/Vagrant.

Sjå òg

Category:API extensions/nn Category:All extensions/nn Category:Beta status extensions/nn Category:Extensions in GitHub version control/nn Category:GPL licensed extensions/nn Category:ScribuntoExternalLibraryPaths extensions/nn