system.chai 1.55 KB
Newer Older
RobLoach's avatar
RobLoach committed
1
// getOS()
RobLoach's avatar
RobLoach committed
2
var os = love.system.getOS()
RobLoach's avatar
RobLoach committed
3
assert_not_equal(os, "", "love.system.getOS()")
RobLoach's avatar
RobLoach committed
4

RobLoach's avatar
RobLoach committed
5
// getVersionString()
RobLoach's avatar
RobLoach committed
6
7
8
var version = love.system.getVersionString()
assert_equal(version[1], '.', "love.system.getVersionString()")

RobLoach's avatar
RobLoach committed
9
// getVersion()
RobLoach's avatar
RobLoach committed
10
11
var versionNumber = love.system.getVersion()
assert_equal(versionNumber[0], 0, "love.system.getVersion()")
RobLoach's avatar
RobLoach committed
12

RobLoach's avatar
RobLoach committed
13
// getUsername()
RobLoach's avatar
RobLoach committed
14
15
var username = love.system.getUsername()
assert(true, "love.system.getUsername() == '" + username + "'")
RobLoach's avatar
RobLoach committed
16

RobLoach's avatar
RobLoach committed
17
// getOS()
RobLoach's avatar
RobLoach committed
18
if (love.system.getOS() == "Linux") {
RobLoach's avatar
RobLoach committed
19
	// Run in foreground.
RobLoach's avatar
RobLoach committed
20
21
22
	var result = love.system.execute("uname")
	assert(result, "love.system.execute('uname')")
}
23
24
25
26
27
28

// setClipboardText()
love.system.setClipboardText("Hello World!")

// getClipboardText
assert_equal(love.system.getClipboardText(), "Hello World!", "love.system.getClipboardText()")
RobLoach's avatar
0.28.0    
RobLoach committed
29
30
31
32
33
34
35

// string::replace()
var replaceSubject = "Hello World! Hello World!"
var newReplaceString = replaceSubject.replace("World", "Space")
assert_equal(newReplaceString, "Hello Space! Hello Space!", "string::replace(string, string)")
newReplaceString = replaceSubject.replace('!', '.')
assert_equal(newReplaceString, "Hello World. Hello World.", "string::replace(char, char)")
RobLoach's avatar
RobLoach committed
36
37
38
39

// string::trim()
var trimSubject = "   Hello World!   "
assert_equal(trimSubject.trim(), "Hello World!", "string::trim()")
RobLoach's avatar
RobLoach committed
40
41
42
43
44
45
46
47

// string::split()
var splitTest = "Hello|How|Are|You"
var splitResult = splitTest.split("|")
assert_equal(splitResult[1], "How", "string::split()")
splitTest = "Rob, John, Loach"
splitResult = splitTest.split(", ")
assert_equal(splitResult[1], "John", "    - commas")