passing more unit tests
This commit is contained in:
parent
21a27f4047
commit
39cf0863e5
@ -45,8 +45,7 @@ public:
|
||||
{
|
||||
register_methods(this, {
|
||||
{"header", &complex::header}, {"item", &complex::item},
|
||||
{"list", &complex::list}, {"empty", &complex::empty}
|
||||
});
|
||||
{"list", &complex::list}, {"empty", &complex::empty}});
|
||||
}
|
||||
|
||||
mstch::node header() {
|
||||
|
@ -1,10 +0,0 @@
|
||||
({
|
||||
name: "Elise",
|
||||
glytch: true,
|
||||
binary: false,
|
||||
value: null,
|
||||
undef: undefined,
|
||||
numeric: function() {
|
||||
return NaN;
|
||||
}
|
||||
})
|
@ -1,14 +0,0 @@
|
||||
({
|
||||
greeting: function () {
|
||||
return "Welcome";
|
||||
},
|
||||
farewell: function () {
|
||||
return "Fair enough, right?";
|
||||
},
|
||||
name: "Chris",
|
||||
value: 10000,
|
||||
taxed_value: function () {
|
||||
return this.value - (this.value * 0.4);
|
||||
},
|
||||
in_ca: true
|
||||
})
|
@ -1,14 +0,0 @@
|
||||
({
|
||||
greeting: function () {
|
||||
return "Welcome";
|
||||
},
|
||||
farewell: function () {
|
||||
return "Fair enough, right?";
|
||||
},
|
||||
name: "Chris",
|
||||
value: 10000,
|
||||
taxed_value: function () {
|
||||
return this.value - (this.value * 0.4);
|
||||
},
|
||||
in_ca: true
|
||||
})
|
@ -1,8 +0,0 @@
|
||||
({
|
||||
name: "Chris",
|
||||
value: 10000,
|
||||
taxed_value: function () {
|
||||
return this.value - (this.value * 0.4);
|
||||
},
|
||||
in_ca: true
|
||||
})
|
6
test/data/null_string.hpp
Normal file
6
test/data/null_string.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
const auto null_string_data = mstch::map{
|
||||
{"name", std::string{"Elise"}},
|
||||
{"glytch", true},
|
||||
{"binary", false},
|
||||
{"value", mstch::node{}}
|
||||
};
|
@ -2,5 +2,3 @@ Hello {{name}}
|
||||
glytch {{glytch}}
|
||||
binary {{binary}}
|
||||
value {{value}}
|
||||
undef {{undef}}
|
||||
numeric {{numeric}}
|
@ -2,5 +2,3 @@ Hello Elise
|
||||
glytch true
|
||||
binary false
|
||||
value
|
||||
undef
|
||||
numeric NaN
|
40
test/data/partial_view.hpp
Normal file
40
test/data/partial_view.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
class partial_view: public mstch::object {
|
||||
private:
|
||||
int m_value;
|
||||
public:
|
||||
partial_view(): m_value{10000} {
|
||||
register_methods(this, {
|
||||
{"greeting", &partial_view::greeting},
|
||||
{"farewell", &partial_view::farewell},
|
||||
{"name", &partial_view::name},
|
||||
{"value", &partial_view::value},
|
||||
{"taxed_value", &partial_view::taxed_value},
|
||||
{"in_ca", &partial_view::in_ca},});
|
||||
}
|
||||
|
||||
mstch::node greeting() {
|
||||
return std::string{"Welcome"};
|
||||
}
|
||||
|
||||
mstch::node farewell() {
|
||||
return std::string{"Fair enough, right?"};
|
||||
}
|
||||
|
||||
mstch::node name() {
|
||||
return std::string{"Chris"};
|
||||
}
|
||||
|
||||
mstch::node value() {
|
||||
return m_value;
|
||||
}
|
||||
|
||||
mstch::node taxed_value() {
|
||||
return static_cast<int>(m_value - (m_value * 0.4));
|
||||
}
|
||||
|
||||
mstch::node in_ca() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
const auto partial_view_data = std::make_shared<partial_view>();
|
40
test/data/partial_whitespace.hpp
Normal file
40
test/data/partial_whitespace.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
class partial_whitespace: public mstch::object {
|
||||
private:
|
||||
int m_value;
|
||||
public:
|
||||
partial_whitespace(): m_value{10000} {
|
||||
register_methods(this, {
|
||||
{"greeting", &partial_whitespace::greeting},
|
||||
{"farewell", &partial_whitespace::farewell},
|
||||
{"name", &partial_whitespace::name},
|
||||
{"value", &partial_whitespace::value},
|
||||
{"taxed_value", &partial_whitespace::taxed_value},
|
||||
{"in_ca", &partial_whitespace::in_ca},});
|
||||
}
|
||||
|
||||
mstch::node greeting() {
|
||||
return std::string{"Welcome"};
|
||||
}
|
||||
|
||||
mstch::node farewell() {
|
||||
return std::string{"Fair enough, right?"};
|
||||
}
|
||||
|
||||
mstch::node name() {
|
||||
return std::string{"Chris"};
|
||||
}
|
||||
|
||||
mstch::node value() {
|
||||
return m_value;
|
||||
}
|
||||
|
||||
mstch::node taxed_value() {
|
||||
return static_cast<int>(m_value - (m_value * 0.4));
|
||||
}
|
||||
|
||||
mstch::node in_ca() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
const auto partial_whitespace_data = std::make_shared<partial_whitespace>();
|
34
test/data/simple.hpp
Normal file
34
test/data/simple.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
class simple: public mstch::object {
|
||||
private:
|
||||
std::string m_name;
|
||||
int m_value;
|
||||
bool m_in_ca;
|
||||
public:
|
||||
simple():
|
||||
m_name{"Chris"},
|
||||
m_value{10000},
|
||||
m_in_ca{true}
|
||||
{
|
||||
register_methods(this, {
|
||||
{"name", &simple::name}, {"value", &simple::value},
|
||||
{"taxed_value", &simple::taxed_value}, {"in_ca", &simple::in_ca}});
|
||||
}
|
||||
|
||||
mstch::node name() {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
mstch::node value() {
|
||||
return m_value;
|
||||
}
|
||||
|
||||
mstch::node taxed_value() {
|
||||
return static_cast<int>(m_value - (m_value * 0.4));
|
||||
}
|
||||
|
||||
mstch::node in_ca() {
|
||||
return m_in_ca;
|
||||
}
|
||||
};
|
||||
|
||||
const auto simple_data = std::make_shared<simple>();
|
@ -47,16 +47,20 @@ MSTCH_TEST(nesting)
|
||||
MSTCH_TEST(nesting_same_name)
|
||||
MSTCH_TEST(null_lookup_array)
|
||||
MSTCH_TEST(null_lookup_object)
|
||||
MSTCH_TEST(null_string)
|
||||
MSTCH_TEST(null_view)
|
||||
MSTCH_PARTIAL_TEST(partial_array)
|
||||
MSTCH_PARTIAL_TEST(partial_array_of_partials)
|
||||
MSTCH_PARTIAL_TEST(partial_array_of_partials_implicit)
|
||||
MSTCH_PARTIAL_TEST(partial_empty)
|
||||
MSTCH_PARTIAL_TEST(partial_template)
|
||||
MSTCH_PARTIAL_TEST(partial_view)
|
||||
MSTCH_PARTIAL_TEST(partial_whitespace)
|
||||
MSTCH_TEST(recursion_with_same_names)
|
||||
MSTCH_TEST(reuse_of_enumerables)
|
||||
MSTCH_TEST(section_as_context)
|
||||
//MSTCH_PARTIAL_TEST(section_functions_in_partials)
|
||||
MSTCH_TEST(simple)
|
||||
MSTCH_TEST(string_as_context)
|
||||
MSTCH_TEST(two_in_a_row)
|
||||
MSTCH_TEST(two_sections)
|
||||
|
Loading…
x
Reference in New Issue
Block a user