mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vlib: add toml module + tests (#11964)
This commit is contained in:
1
vlib/toml/tests/testdata/json_test.out
vendored
Normal file
1
vlib/toml/tests/testdata/json_test.out
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "v": true, "animal": { "type": { "name": "pug" } }, "inline": { "a": 4, "b.c": 6, "b": { "c": 7 } }, "db": { "t": true }, "ij": { "a": { "i": 1, "j": 2 }, "b": { "i": "3", "j": "4" } }, "fruit": { "apple": { "color": "red", "taste": { "sweet": true }, "texture": { "smooth": true } } } }
|
||||
25
vlib/toml/tests/testdata/json_test.toml
vendored
Normal file
25
vlib/toml/tests/testdata/json_test.toml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
v = true
|
||||
|
||||
animal = { type.name = "pug" }
|
||||
|
||||
inline = { "a" = 4, "b.c" = 6, b.c = 7 }
|
||||
|
||||
[db]
|
||||
t = true
|
||||
|
||||
[ij]
|
||||
[ij.a]
|
||||
i = 1
|
||||
j = 2
|
||||
|
||||
[ij.b]
|
||||
i = "3"
|
||||
j = "4"
|
||||
|
||||
[fruit]
|
||||
apple.color = "red"
|
||||
apple.taste.sweet = true
|
||||
|
||||
[fruit.apple.texture]
|
||||
smooth = true
|
||||
15
vlib/toml/tests/testdata/strings_test.toml
vendored
Normal file
15
vlib/toml/tests/testdata/strings_test.toml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Make sure that quotes inside multiline strings are allowed, including right
|
||||
# after the opening '''/""" and before the closing '''/"""
|
||||
|
||||
lit_one = ''''one quote''''
|
||||
lit_two = '''''two quotes'''''
|
||||
lit_one_space = ''' 'one quote' '''
|
||||
lit_two_space = ''' ''two quotes'' '''
|
||||
|
||||
one = """"one quote""""
|
||||
two = """""two quotes"""""
|
||||
one_space = """ "one quote" """
|
||||
two_space = """ ""two quotes"" """
|
||||
|
||||
mismatch1 = """aaa'''bbb"""
|
||||
mismatch2 = '''aaa"""bbb'''
|
||||
1
vlib/toml/tests/testdata/toml_test.out
vendored
Normal file
1
vlib/toml/tests/testdata/toml_test.out
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "title": "TOML Example", "owner": { "name": "Tom Preston-Werner", "dob": "1979-05-27T07:32:00-08:00" }, "database": { "server": "192.168.1.1", "ports": [ 8000, 8001, 8002 ], "connection_max": 5000, "enabled": true }, "servers": { "alpha": { "ip": "10.0.0.1", "dc": "eqdc10" }, "beta": { "ip": "10.0.0.2", "dc": "eqdc10" } }, "clients": { "data": [ [ "gamma", "delta" ], [ 1, 2 ] ], "hosts": [ "alpha", "omega" ] } }
|
||||
33
vlib/toml/tests/testdata/toml_test.toml
vendored
Normal file
33
vlib/toml/tests/testdata/toml_test.toml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# This is a TOML document.
|
||||
|
||||
title = "TOML Example"
|
||||
|
||||
[owner]
|
||||
name = "Tom Preston-Werner"
|
||||
dob = 1979-05-27T07:32:00-08:00 # First class dates
|
||||
|
||||
[database]
|
||||
server = "192.168.1.1"
|
||||
ports = [ 8000, 8001, 8002 ]
|
||||
connection_max = 5000
|
||||
enabled = true
|
||||
|
||||
[servers]
|
||||
|
||||
# Indentation (tabs and/or spaces) is allowed but not required
|
||||
[servers.alpha]
|
||||
ip = "10.0.0.1"
|
||||
dc = "eqdc10"
|
||||
|
||||
[servers.beta]
|
||||
ip = "10.0.0.2"
|
||||
dc = "eqdc10"
|
||||
|
||||
[clients]
|
||||
data = [ ["gamma", "delta"], [1, 2] ]
|
||||
|
||||
# Line breaks are OK when inside arrays
|
||||
hosts = [
|
||||
"alpha",
|
||||
"omega"
|
||||
]
|
||||
Reference in New Issue
Block a user