-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
9,884 additions
and
1 deletion.
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 @@ | ||
-- This is a dummy lua file |
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,66 @@ | ||
import URL, decodeURIComponent from include "url.yue" | ||
urltestdata = include "urltestdata.lua" | ||
|
||
-- First let's decode the test data | ||
for test in *urltestdata | ||
if istable(test) | ||
for key, value in pairs test | ||
if isstring value | ||
test[key] = decodeURIComponent(value) | ||
|
||
cases = {} | ||
for test in *urltestdata | ||
if isstring(test) | ||
cases[] = { name: test, func: -> } | ||
continue | ||
|
||
prefix = (test.base and test.base != "about:blank") and "(#{test.base}) " or "" | ||
name = "#{prefix}#{test.input} -> #{not test.failure and test.href or "failure"}" | ||
func = -> | ||
ok, url = pcall(URL, test.input, --[[test.base != "about:blank" and]] test.base) | ||
if test.failure | ||
if ok | ||
print "expected failure but got: #{url.href}" | ||
-- return -- fix later | ||
expect(ok).to.beFalse() | ||
return | ||
|
||
if not ok | ||
print "failed to parse: #{url}" | ||
expect(ok).to.beTrue() | ||
|
||
expect(url.protocol).to.eq(test.protocol) | ||
|
||
if test.password != "" | ||
expect(url.password).to.eq(test.password) | ||
|
||
if test.username != "" | ||
expect(url.username).to.eq(test.username) | ||
|
||
if test.hostname != "" | ||
expect(url.hostname).to.eq(test.hostname) | ||
|
||
port = tonumber test.port | ||
if port | ||
expect(url.port).to.eq(port) | ||
|
||
expect(url.host).to.eq(test.host) | ||
if test.origin and test.origin != "null" | ||
expect(url.origin).to.eq(test.origin) | ||
|
||
if test.pathname != "" | ||
expect(url.pathname).to.eq(test.pathname) | ||
-- expect(url.search).to.eq(test.search) | ||
-- expect(url.hash).to.eq(test.hash) | ||
-- expect(url.href).to.eq(test.href) | ||
|
||
|
||
return | ||
|
||
|
||
cases[] = { :name, :func } | ||
|
||
return { | ||
:cases, | ||
groupName: "gm_url whatwg-url tests" | ||
} |
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 @@ | ||
../../../url.yue |
Oops, something went wrong.