sassc 1.7.1 → 1.8.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/ext/libsass/.gitignore +10 -6
- data/ext/libsass/.travis.yml +4 -1
- data/ext/libsass/GNUmakefile.am +88 -0
- data/ext/libsass/Makefile +157 -76
- data/ext/libsass/Makefile.conf +47 -0
- data/ext/libsass/Readme.md +13 -14
- data/ext/libsass/appveyor.yml +25 -41
- data/ext/libsass/configure.ac +20 -7
- data/ext/libsass/contrib/plugin.cpp +1 -1
- data/ext/libsass/include/sass.h +15 -0
- data/ext/libsass/{sass.h → include/sass/base.h} +17 -9
- data/ext/libsass/{sass_context.h → include/sass/context.h} +3 -1
- data/ext/libsass/{sass_functions.h → include/sass/functions.h} +4 -4
- data/ext/libsass/{sass_interface.h → include/sass/interface.h} +5 -2
- data/ext/libsass/{sass_values.h → include/sass/values.h} +15 -1
- data/ext/libsass/{sass_version.h → include/sass/version.h} +0 -0
- data/ext/libsass/{sass_version.h.in → include/sass/version.h.in} +0 -0
- data/ext/libsass/{sass2scss.h → include/sass2scss.h} +6 -7
- data/ext/libsass/m4/m4-ax_cxx_compile_stdcxx_11.m4 +167 -0
- data/ext/libsass/script/ci-build-libsass +67 -23
- data/ext/libsass/src/GNUmakefile.am +54 -0
- data/ext/libsass/src/ast.cpp +2029 -0
- data/ext/libsass/{ast.hpp → src/ast.hpp} +832 -660
- data/ext/libsass/src/ast_def_macros.hpp +47 -0
- data/ext/libsass/src/ast_factory.hpp +93 -0
- data/ext/libsass/{ast_fwd_decl.hpp → src/ast_fwd_decl.hpp} +9 -4
- data/ext/libsass/{b64 → src/b64}/cencode.h +1 -1
- data/ext/libsass/{b64 → src/b64}/encode.h +0 -0
- data/ext/libsass/{backtrace.hpp → src/backtrace.hpp} +9 -10
- data/ext/libsass/{base64vlq.cpp → src/base64vlq.cpp} +2 -2
- data/ext/libsass/{base64vlq.hpp → src/base64vlq.hpp} +1 -2
- data/ext/libsass/{bind.cpp → src/bind.cpp} +96 -59
- data/ext/libsass/{bind.hpp → src/bind.hpp} +1 -1
- data/ext/libsass/src/c99func.c +54 -0
- data/ext/libsass/{cencode.c → src/cencode.c} +5 -5
- data/ext/libsass/src/color_maps.cpp +643 -0
- data/ext/libsass/src/color_maps.hpp +333 -0
- data/ext/libsass/{constants.cpp → src/constants.cpp} +10 -1
- data/ext/libsass/{constants.hpp → src/constants.hpp} +7 -0
- data/ext/libsass/{context.cpp → src/context.cpp} +152 -122
- data/ext/libsass/src/context.hpp +150 -0
- data/ext/libsass/{cssize.cpp → src/cssize.cpp} +123 -109
- data/ext/libsass/{cssize.hpp → src/cssize.hpp} +9 -13
- data/ext/libsass/{debug.hpp → src/debug.hpp} +9 -9
- data/ext/libsass/src/debugger.hpp +683 -0
- data/ext/libsass/{emitter.cpp → src/emitter.cpp} +13 -13
- data/ext/libsass/{emitter.hpp → src/emitter.hpp} +10 -11
- data/ext/libsass/src/environment.cpp +184 -0
- data/ext/libsass/src/environment.hpp +92 -0
- data/ext/libsass/src/error_handling.cpp +46 -0
- data/ext/libsass/src/error_handling.hpp +34 -0
- data/ext/libsass/src/eval.cpp +1462 -0
- data/ext/libsass/src/eval.hpp +107 -0
- data/ext/libsass/src/expand.cpp +653 -0
- data/ext/libsass/{expand.hpp → src/expand.hpp} +17 -16
- data/ext/libsass/{extend.cpp → src/extend.cpp} +198 -139
- data/ext/libsass/{extend.hpp → src/extend.hpp} +7 -8
- data/ext/libsass/{file.cpp → src/file.cpp} +103 -57
- data/ext/libsass/{file.hpp → src/file.hpp} +23 -14
- data/ext/libsass/{functions.cpp → src/functions.cpp} +642 -333
- data/ext/libsass/{functions.hpp → src/functions.hpp} +17 -4
- data/ext/libsass/{inspect.cpp → src/inspect.cpp} +147 -260
- data/ext/libsass/{inspect.hpp → src/inspect.hpp} +7 -7
- data/ext/libsass/{json.cpp → src/json.cpp} +33 -43
- data/ext/libsass/{json.hpp → src/json.hpp} +1 -1
- data/ext/libsass/{kwd_arg_macros.hpp → src/kwd_arg_macros.hpp} +0 -0
- data/ext/libsass/{lexer.cpp → src/lexer.cpp} +28 -0
- data/ext/libsass/{lexer.hpp → src/lexer.hpp} +25 -10
- data/ext/libsass/{listize.cpp → src/listize.cpp} +17 -13
- data/ext/libsass/{listize.hpp → src/listize.hpp} +0 -2
- data/ext/libsass/{mapping.hpp → src/mapping.hpp} +0 -0
- data/ext/libsass/src/memory_manager.cpp +76 -0
- data/ext/libsass/src/memory_manager.hpp +48 -0
- data/ext/libsass/{node.cpp → src/node.cpp} +89 -18
- data/ext/libsass/{node.hpp → src/node.hpp} +5 -6
- data/ext/libsass/{operation.hpp → src/operation.hpp} +18 -12
- data/ext/libsass/{output.cpp → src/output.cpp} +47 -55
- data/ext/libsass/{output.hpp → src/output.hpp} +5 -4
- data/ext/libsass/src/parser.cpp +2529 -0
- data/ext/libsass/{parser.hpp → src/parser.hpp} +84 -60
- data/ext/libsass/{paths.hpp → src/paths.hpp} +10 -13
- data/ext/libsass/{plugins.cpp → src/plugins.cpp} +14 -17
- data/ext/libsass/{plugins.hpp → src/plugins.hpp} +10 -11
- data/ext/libsass/{position.cpp → src/position.cpp} +5 -6
- data/ext/libsass/{position.hpp → src/position.hpp} +19 -22
- data/ext/libsass/{prelexer.cpp → src/prelexer.cpp} +401 -53
- data/ext/libsass/{prelexer.hpp → src/prelexer.hpp} +50 -10
- data/ext/libsass/{remove_placeholders.cpp → src/remove_placeholders.cpp} +12 -16
- data/ext/libsass/{remove_placeholders.hpp → src/remove_placeholders.hpp} +1 -7
- data/ext/libsass/{sass.cpp → src/sass.cpp} +3 -5
- data/ext/libsass/{sass2scss.cpp → src/sass2scss.cpp} +51 -46
- data/ext/libsass/{sass_context.cpp → src/sass_context.cpp} +114 -112
- data/ext/libsass/{sass_functions.cpp → src/sass_functions.cpp} +11 -18
- data/ext/libsass/{sass_interface.cpp → src/sass_interface.cpp} +44 -81
- data/ext/libsass/{sass_util.cpp → src/sass_util.cpp} +26 -8
- data/ext/libsass/{sass_util.hpp → src/sass_util.hpp} +14 -18
- data/ext/libsass/{sass_values.cpp → src/sass_values.cpp} +91 -20
- data/ext/libsass/{source_map.cpp → src/source_map.cpp} +13 -13
- data/ext/libsass/{source_map.hpp → src/source_map.hpp} +9 -9
- data/ext/libsass/{subset_map.hpp → src/subset_map.hpp} +29 -31
- data/ext/libsass/{support → src/support}/libsass.pc.in +0 -0
- data/ext/libsass/src/to_c.cpp +73 -0
- data/ext/libsass/src/to_c.hpp +41 -0
- data/ext/libsass/src/to_string.cpp +47 -0
- data/ext/libsass/{to_string.hpp → src/to_string.hpp} +9 -7
- data/ext/libsass/src/to_value.cpp +109 -0
- data/ext/libsass/src/to_value.hpp +50 -0
- data/ext/libsass/{units.cpp → src/units.cpp} +56 -51
- data/ext/libsass/{units.hpp → src/units.hpp} +8 -9
- data/ext/libsass/{utf8.h → src/utf8.h} +0 -0
- data/ext/libsass/{utf8 → src/utf8}/checked.h +0 -0
- data/ext/libsass/{utf8 → src/utf8}/core.h +12 -12
- data/ext/libsass/{utf8 → src/utf8}/unchecked.h +0 -0
- data/ext/libsass/{utf8_string.cpp → src/utf8_string.cpp} +0 -0
- data/ext/libsass/{utf8_string.hpp → src/utf8_string.hpp} +6 -6
- data/ext/libsass/{util.cpp → src/util.cpp} +144 -86
- data/ext/libsass/src/util.hpp +59 -0
- data/ext/libsass/src/values.cpp +137 -0
- data/ext/libsass/src/values.hpp +12 -0
- data/ext/libsass/test/test_node.cpp +33 -33
- data/ext/libsass/test/test_paths.cpp +5 -6
- data/ext/libsass/test/test_selector_difference.cpp +4 -5
- data/ext/libsass/test/test_specificity.cpp +4 -5
- data/ext/libsass/test/test_subset_map.cpp +91 -91
- data/ext/libsass/test/test_superselector.cpp +11 -11
- data/ext/libsass/test/test_unification.cpp +4 -4
- data/ext/libsass/win/libsass.targets +101 -0
- data/ext/libsass/win/libsass.vcxproj +45 -127
- data/ext/libsass/win/libsass.vcxproj.filters +303 -0
- data/lib/sassc/import_handler.rb +1 -1
- data/lib/sassc/native/native_functions_api.rb +3 -3
- data/lib/sassc/version.rb +1 -1
- data/test/custom_importer_test.rb +1 -4
- data/test/functions_test.rb +3 -2
- data/test/native_test.rb +4 -3
- metadata +117 -110
- data/ext/libsass/Makefile.am +0 -146
- data/ext/libsass/ast.cpp +0 -945
- data/ext/libsass/ast_def_macros.hpp +0 -21
- data/ext/libsass/ast_factory.hpp +0 -92
- data/ext/libsass/color_names.hpp +0 -327
- data/ext/libsass/context.hpp +0 -157
- data/ext/libsass/contextualize.cpp +0 -148
- data/ext/libsass/contextualize.hpp +0 -46
- data/ext/libsass/contextualize_eval.cpp +0 -93
- data/ext/libsass/contextualize_eval.hpp +0 -44
- data/ext/libsass/debugger.hpp +0 -558
- data/ext/libsass/environment.hpp +0 -163
- data/ext/libsass/error_handling.cpp +0 -35
- data/ext/libsass/error_handling.hpp +0 -32
- data/ext/libsass/eval.cpp +0 -1392
- data/ext/libsass/eval.hpp +0 -88
- data/ext/libsass/expand.cpp +0 -575
- data/ext/libsass/memory_manager.hpp +0 -57
- data/ext/libsass/parser.cpp +0 -2403
- data/ext/libsass/posix/getopt.c +0 -562
- data/ext/libsass/posix/getopt.h +0 -95
- data/ext/libsass/to_c.cpp +0 -61
- data/ext/libsass/to_c.hpp +0 -44
- data/ext/libsass/to_string.cpp +0 -34
- data/ext/libsass/util.hpp +0 -54
- data/ext/libsass/win/libsass.filters +0 -312
@@ -0,0 +1,59 @@
|
|
1
|
+
#ifndef SASS_UTIL_H
|
2
|
+
#define SASS_UTIL_H
|
3
|
+
|
4
|
+
#include <vector>
|
5
|
+
#include <string>
|
6
|
+
#include <assert.h>
|
7
|
+
#include "ast_fwd_decl.hpp"
|
8
|
+
|
9
|
+
#define SASS_ASSERT(cond, msg) assert(cond && msg)
|
10
|
+
|
11
|
+
namespace Sass {
|
12
|
+
|
13
|
+
char* sass_strdup(const char* str);
|
14
|
+
double sass_atof(const char* str);
|
15
|
+
const char* safe_str(const char *);
|
16
|
+
void free_string_array(char **);
|
17
|
+
char **copy_strings(const std::vector<std::string>&, char ***, int = 0);
|
18
|
+
std::string string_escape(const std::string& str);
|
19
|
+
std::string string_unescape(const std::string& str);
|
20
|
+
std::string string_eval_escapes(const std::string& str);
|
21
|
+
std::string read_css_string(const std::string& str);
|
22
|
+
std::string evacuate_quotes(const std::string& str);
|
23
|
+
std::string evacuate_escapes(const std::string& str);
|
24
|
+
std::string string_to_output(const std::string& str);
|
25
|
+
std::string comment_to_string(const std::string& text);
|
26
|
+
std::string normalize_wspace(const std::string& str);
|
27
|
+
|
28
|
+
std::string quote(const std::string&, char q = 0, bool keep_linefeed_whitespace = false);
|
29
|
+
std::string unquote(const std::string&, char* q = 0, bool keep_utf8_sequences = false);
|
30
|
+
char detect_best_quotemark(const char* s, char qm = '"');
|
31
|
+
|
32
|
+
bool is_hex_doublet(double n);
|
33
|
+
bool is_color_doublet(double r, double g, double b);
|
34
|
+
|
35
|
+
bool peek_linefeed(const char* start);
|
36
|
+
|
37
|
+
namespace Util {
|
38
|
+
|
39
|
+
std::string rtrim(const std::string& str);
|
40
|
+
|
41
|
+
std::string normalize_underscores(const std::string& str);
|
42
|
+
std::string normalize_decimals(const std::string& str);
|
43
|
+
std::string normalize_sixtuplet(const std::string& col);
|
44
|
+
|
45
|
+
std::string vecJoin(const std::vector<std::string>& vec, const std::string& sep);
|
46
|
+
bool containsAnyPrintableStatements(Block* b);
|
47
|
+
|
48
|
+
bool isPrintable(Ruleset* r, Output_Style style = NESTED);
|
49
|
+
bool isPrintable(Supports_Block* r, Output_Style style = NESTED);
|
50
|
+
bool isPrintable(Media_Block* r, Output_Style style = NESTED);
|
51
|
+
bool isPrintable(Block* b, Output_Style style = NESTED);
|
52
|
+
bool isPrintable(String_Constant* s, Output_Style style = NESTED);
|
53
|
+
bool isPrintable(String_Quoted* s, Output_Style style = NESTED);
|
54
|
+
bool isPrintable(Declaration* d, Output_Style style = NESTED);
|
55
|
+
bool isAscii(const char chr);
|
56
|
+
|
57
|
+
}
|
58
|
+
}
|
59
|
+
#endif
|
@@ -0,0 +1,137 @@
|
|
1
|
+
#include "sass.h"
|
2
|
+
#include "values.hpp"
|
3
|
+
|
4
|
+
#include <stdint.h>
|
5
|
+
|
6
|
+
namespace Sass {
|
7
|
+
|
8
|
+
// convert value from C++ side to C-API
|
9
|
+
union Sass_Value* ast_node_to_sass_value (const Expression* val)
|
10
|
+
{
|
11
|
+
if (val->concrete_type() == Expression::NUMBER)
|
12
|
+
{
|
13
|
+
const Number* res = dynamic_cast<const Number*>(val);
|
14
|
+
return sass_make_number(res->value(), res->unit().c_str());
|
15
|
+
}
|
16
|
+
else if (val->concrete_type() == Expression::COLOR)
|
17
|
+
{
|
18
|
+
const Color* col = dynamic_cast<const Color*>(val);
|
19
|
+
return sass_make_color(col->r(), col->g(), col->b(), col->a());
|
20
|
+
}
|
21
|
+
else if (val->concrete_type() == Expression::LIST)
|
22
|
+
{
|
23
|
+
const List* l = dynamic_cast<const List*>(val);
|
24
|
+
union Sass_Value* list = sass_make_list(l->size(), l->separator());
|
25
|
+
for (size_t i = 0, L = l->length(); i < L; ++i) {
|
26
|
+
auto val = ast_node_to_sass_value((*l)[i]);
|
27
|
+
sass_list_set_value(list, i, val);
|
28
|
+
}
|
29
|
+
return list;
|
30
|
+
}
|
31
|
+
else if (val->concrete_type() == Expression::MAP)
|
32
|
+
{
|
33
|
+
const Map* m = dynamic_cast<const Map*>(val);
|
34
|
+
union Sass_Value* map = sass_make_map(m->length());
|
35
|
+
size_t i = 0; for (auto key : m->keys()) {
|
36
|
+
sass_map_set_key(map, i, ast_node_to_sass_value(key));
|
37
|
+
sass_map_set_value(map, i, ast_node_to_sass_value(m->at(key)));
|
38
|
+
++ i;
|
39
|
+
}
|
40
|
+
return map;
|
41
|
+
}
|
42
|
+
else if (val->concrete_type() == Expression::NULL_VAL)
|
43
|
+
{
|
44
|
+
return sass_make_null();
|
45
|
+
}
|
46
|
+
else if (val->concrete_type() == Expression::BOOLEAN)
|
47
|
+
{
|
48
|
+
const Boolean* res = dynamic_cast<const Boolean*>(val);
|
49
|
+
return sass_make_boolean(res->value());
|
50
|
+
}
|
51
|
+
else if (val->concrete_type() == Expression::STRING)
|
52
|
+
{
|
53
|
+
if (const String_Quoted* qstr = dynamic_cast<const String_Quoted*>(val))
|
54
|
+
{
|
55
|
+
return sass_make_qstring(qstr->value().c_str());
|
56
|
+
}
|
57
|
+
else if (const String_Constant* cstr = dynamic_cast<const String_Constant*>(val))
|
58
|
+
{
|
59
|
+
return sass_make_string(cstr->value().c_str());
|
60
|
+
}
|
61
|
+
}
|
62
|
+
return sass_make_error("unknown sass value type");
|
63
|
+
}
|
64
|
+
|
65
|
+
// convert value from C-API to C++ side
|
66
|
+
Value* sass_value_to_ast_node (Memory_Manager& mem, const union Sass_Value* val)
|
67
|
+
{
|
68
|
+
switch (sass_value_get_tag(val)) {
|
69
|
+
case SASS_NUMBER:
|
70
|
+
return SASS_MEMORY_NEW(mem, Number,
|
71
|
+
ParserState("[C-VALUE]"),
|
72
|
+
sass_number_get_value(val),
|
73
|
+
sass_number_get_unit(val));
|
74
|
+
break;
|
75
|
+
case SASS_BOOLEAN:
|
76
|
+
return SASS_MEMORY_NEW(mem, Boolean,
|
77
|
+
ParserState("[C-VALUE]"),
|
78
|
+
sass_boolean_get_value(val));
|
79
|
+
break;
|
80
|
+
case SASS_COLOR:
|
81
|
+
return SASS_MEMORY_NEW(mem, Color,
|
82
|
+
ParserState("[C-VALUE]"),
|
83
|
+
sass_color_get_r(val),
|
84
|
+
sass_color_get_g(val),
|
85
|
+
sass_color_get_b(val),
|
86
|
+
sass_color_get_a(val));
|
87
|
+
break;
|
88
|
+
case SASS_STRING:
|
89
|
+
if (sass_string_is_quoted(val)) {
|
90
|
+
return SASS_MEMORY_NEW(mem, String_Quoted,
|
91
|
+
ParserState("[C-VALUE]"),
|
92
|
+
sass_string_get_value(val));
|
93
|
+
} else {
|
94
|
+
return SASS_MEMORY_NEW(mem, String_Constant,
|
95
|
+
ParserState("[C-VALUE]"),
|
96
|
+
sass_string_get_value(val));
|
97
|
+
}
|
98
|
+
break;
|
99
|
+
case SASS_LIST: {
|
100
|
+
List* l = SASS_MEMORY_NEW(mem, List,
|
101
|
+
ParserState("[C-VALUE]"),
|
102
|
+
sass_list_get_length(val),
|
103
|
+
sass_list_get_separator(val));
|
104
|
+
for (size_t i = 0, L = sass_list_get_length(val); i < L; ++i) {
|
105
|
+
*l << sass_value_to_ast_node(mem, sass_list_get_value(val, i));
|
106
|
+
}
|
107
|
+
return l;
|
108
|
+
}
|
109
|
+
break;
|
110
|
+
case SASS_MAP: {
|
111
|
+
Map* m = SASS_MEMORY_NEW(mem, Map, ParserState("[C-VALUE]"));
|
112
|
+
for (size_t i = 0, L = sass_map_get_length(val); i < L; ++i) {
|
113
|
+
*m << std::make_pair(
|
114
|
+
sass_value_to_ast_node(mem, sass_map_get_key(val, i)),
|
115
|
+
sass_value_to_ast_node(mem, sass_map_get_value(val, i)));
|
116
|
+
}
|
117
|
+
return m;
|
118
|
+
}
|
119
|
+
break;
|
120
|
+
case SASS_NULL:
|
121
|
+
return SASS_MEMORY_NEW(mem, Null, ParserState("[C-VALUE]"));
|
122
|
+
break;
|
123
|
+
case SASS_ERROR:
|
124
|
+
return SASS_MEMORY_NEW(mem, Custom_Error,
|
125
|
+
ParserState("[C-VALUE]"),
|
126
|
+
sass_error_get_message(val));
|
127
|
+
break;
|
128
|
+
case SASS_WARNING:
|
129
|
+
return SASS_MEMORY_NEW(mem, Custom_Warning,
|
130
|
+
ParserState("[C-VALUE]"),
|
131
|
+
sass_warning_get_message(val));
|
132
|
+
break;
|
133
|
+
}
|
134
|
+
return 0;
|
135
|
+
}
|
136
|
+
|
137
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#ifndef SASS_VALUES_H
|
2
|
+
#define SASS_VALUES_H
|
3
|
+
|
4
|
+
#include "ast.hpp"
|
5
|
+
|
6
|
+
namespace Sass {
|
7
|
+
|
8
|
+
union Sass_Value* ast_node_to_sass_value (const Expression* val);
|
9
|
+
Value* sass_value_to_ast_node (Memory_Manager& mem, const union Sass_Value* val);
|
10
|
+
|
11
|
+
}
|
12
|
+
#endif
|
@@ -10,16 +10,16 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
namespace Sass {
|
13
|
-
|
13
|
+
|
14
14
|
Context ctx = Context::Data();
|
15
|
-
|
15
|
+
|
16
16
|
To_String to_string;
|
17
|
-
|
18
|
-
|
17
|
+
|
18
|
+
|
19
19
|
const char* const ROUNDTRIP_TESTS[] = {
|
20
20
|
NULL,
|
21
|
-
|
22
|
-
|
21
|
+
"~",
|
22
|
+
"CMPD",
|
23
23
|
"~ CMPD",
|
24
24
|
"CMPD >",
|
25
25
|
"> > CMPD",
|
@@ -29,15 +29,15 @@ namespace Sass {
|
|
29
29
|
"+ CMPD1 CMPD2 ~ CMPD3 + CMPD4 > CMPD5 > ~"
|
30
30
|
};
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
static Complex_Selector* createComplexSelector(string src) {
|
35
|
-
string temp(src);
|
32
|
+
|
33
|
+
|
34
|
+
static Complex_Selector* createComplexSelector(std::string src) {
|
35
|
+
std::string temp(src);
|
36
36
|
temp += ";";
|
37
|
-
return (*Parser::from_c_str(temp.c_str(), ctx, "", Position()).
|
37
|
+
return (*Parser::from_c_str(temp.c_str(), ctx, "", Position()).parse_selector_list())[0];
|
38
38
|
}
|
39
|
-
|
40
|
-
|
39
|
+
|
40
|
+
|
41
41
|
void roundtripTest(const char* toTest) {
|
42
42
|
|
43
43
|
// Create the initial selector
|
@@ -46,53 +46,53 @@ namespace Sass {
|
|
46
46
|
if (toTest) {
|
47
47
|
pOrigSelector = createComplexSelector(toTest);
|
48
48
|
}
|
49
|
-
|
50
|
-
string expected(pOrigSelector ? pOrigSelector->perform(&to_string) : "NULL");
|
51
|
-
|
52
|
-
|
49
|
+
|
50
|
+
std::string expected(pOrigSelector ? pOrigSelector->perform(&to_string) : "NULL");
|
51
|
+
|
52
|
+
|
53
53
|
// Roundtrip the selector into a node and back
|
54
|
-
|
54
|
+
|
55
55
|
Node node = complexSelectorToNode(pOrigSelector, ctx);
|
56
|
-
|
57
|
-
stringstream nodeStringStream;
|
56
|
+
|
57
|
+
std::stringstream nodeStringStream;
|
58
58
|
nodeStringStream << node;
|
59
|
-
string nodeString = nodeStringStream.str();
|
59
|
+
std::string nodeString = nodeStringStream.str();
|
60
60
|
cout << "ASNODE: " << node << endl;
|
61
|
-
|
61
|
+
|
62
62
|
Complex_Selector* pNewSelector = nodeToComplexSelector(node, ctx);
|
63
|
-
|
63
|
+
|
64
64
|
// Show the result
|
65
65
|
|
66
|
-
string result(pNewSelector ? pNewSelector->perform(&to_string) : "NULL");
|
67
|
-
|
66
|
+
std::string result(pNewSelector ? pNewSelector->perform(&to_string) : "NULL");
|
67
|
+
|
68
68
|
cout << "SELECTOR: " << expected << endl;
|
69
69
|
cout << "NEW SELECTOR: " << result << endl;
|
70
70
|
|
71
|
-
|
71
|
+
|
72
72
|
// Test that they are equal using the equality operator
|
73
|
-
|
73
|
+
|
74
74
|
assert( (!pOrigSelector && !pNewSelector ) || (pOrigSelector && pNewSelector) );
|
75
75
|
if (pOrigSelector) {
|
76
|
-
|
76
|
+
assert( *pOrigSelector == *pNewSelector );
|
77
77
|
}
|
78
78
|
|
79
|
-
|
79
|
+
|
80
80
|
// Test that they are equal by comparing the string versions of the selectors
|
81
81
|
|
82
82
|
assert(expected == result);
|
83
|
-
|
83
|
+
|
84
84
|
}
|
85
85
|
|
86
86
|
|
87
|
-
|
87
|
+
int main() {
|
88
88
|
for (int index = 0; index < STATIC_ARRAY_SIZE(ROUNDTRIP_TESTS); index++) {
|
89
89
|
const char* const toTest = ROUNDTRIP_TESTS[index];
|
90
90
|
cout << "\nINPUT STRING: " << (toTest ? toTest : "NULL") << endl;
|
91
91
|
roundtripTest(toTest);
|
92
92
|
}
|
93
|
-
|
93
|
+
|
94
94
|
cout << "\nTesting Done.\n";
|
95
95
|
}
|
96
96
|
|
97
97
|
|
98
|
-
}
|
98
|
+
}
|
@@ -1,11 +1,10 @@
|
|
1
1
|
#include <iostream>
|
2
2
|
#include "../paths.hpp"
|
3
3
|
|
4
|
-
using namespace std;
|
5
4
|
using namespace Sass;
|
6
5
|
|
7
6
|
template<typename T>
|
8
|
-
vector<T>& operator<<(vector<T>& v, const T& e)
|
7
|
+
std::vector<T>& operator<<(std::vector<T>& v, const T& e)
|
9
8
|
{
|
10
9
|
v.push_back(e);
|
11
10
|
return v;
|
@@ -13,17 +12,17 @@ vector<T>& operator<<(vector<T>& v, const T& e)
|
|
13
12
|
|
14
13
|
int main()
|
15
14
|
{
|
16
|
-
vector<int> v1, v2, v3;
|
15
|
+
std::vector<int> v1, v2, v3;
|
17
16
|
v1 << 1 << 2;
|
18
17
|
v2 << 3;
|
19
18
|
v3 << 4 << 5 << 6;
|
20
19
|
|
21
|
-
vector<vector<int> > ss;
|
20
|
+
std::vector<std::vector<int> > ss;
|
22
21
|
ss << v1 << v2 << v3;
|
23
22
|
|
24
|
-
vector<vector<int> > ps = paths(ss);
|
23
|
+
std::vector<std::vector<int> > ps = paths(ss);
|
25
24
|
for (size_t i = 0, S = ps.size(); i < S; ++i) {
|
26
|
-
cout << vector_to_string(ps[i]) << endl;
|
25
|
+
std::cout << vector_to_string(ps[i]) << std::endl;
|
27
26
|
}
|
28
27
|
return 0;
|
29
28
|
}
|
@@ -5,18 +5,17 @@
|
|
5
5
|
#include <string>
|
6
6
|
#include <iostream>
|
7
7
|
|
8
|
-
using namespace std;
|
9
8
|
using namespace Sass;
|
10
9
|
|
11
10
|
Context ctx = Context::Data();
|
12
11
|
To_String to_string;
|
13
12
|
|
14
|
-
Compound_Selector* selector(string src)
|
15
|
-
{ return Parser::from_c_str(src.c_str(), ctx, "", Position()).
|
13
|
+
Compound_Selector* selector(std::string src)
|
14
|
+
{ return Parser::from_c_str(src.c_str(), ctx, "", Position()).parse_compound_selector(); }
|
16
15
|
|
17
|
-
void diff(string s, string t)
|
16
|
+
void diff(std::string s, std::string t)
|
18
17
|
{
|
19
|
-
cout << s << " - " << t << " = " << selector(s + ";")->minus(selector(t + ";"), ctx)->perform(&to_string) << endl;
|
18
|
+
std::cout << s << " - " << t << " = " << selector(s + ";")->minus(selector(t + ";"), ctx)->perform(&to_string) << std::endl;
|
20
19
|
}
|
21
20
|
|
22
21
|
int main()
|
@@ -5,17 +5,16 @@
|
|
5
5
|
#include <string>
|
6
6
|
#include <iostream>
|
7
7
|
|
8
|
-
using namespace std;
|
9
8
|
using namespace Sass;
|
10
9
|
|
11
10
|
Context ctx = Context::Data();
|
12
11
|
To_String to_string;
|
13
12
|
|
14
|
-
Selector* selector(string src)
|
15
|
-
{ return Parser::from_c_str(src.c_str(), ctx, "", Position()).
|
13
|
+
Selector* selector(std::string src)
|
14
|
+
{ return Parser::from_c_str(src.c_str(), ctx, "", Position()).parse_selector_list(); }
|
16
15
|
|
17
|
-
void spec(string sel)
|
18
|
-
{ cout << sel << "\t::\t" << selector(sel + ";")->specificity() << endl; }
|
16
|
+
void spec(std::string sel)
|
17
|
+
{ std::cout << sel << "\t::\t" << selector(sel + ";")->specificity() << std::endl; }
|
19
18
|
|
20
19
|
int main()
|
21
20
|
{
|
@@ -3,171 +3,171 @@
|
|
3
3
|
#include <assert.h>
|
4
4
|
#include "../subset_map.hpp"
|
5
5
|
|
6
|
-
Subset_Map<string, string> ssm;
|
6
|
+
Subset_Map<std::string, std::string> ssm;
|
7
7
|
|
8
|
-
string toString(vector<string> v);
|
9
|
-
string toString(vector<pair<string, vector<string>>> v);
|
10
|
-
void assertEqual(string sExpected, string sResult);
|
8
|
+
string toString(std::vector<std::string> v);
|
9
|
+
string toString(std::vector<std::pair<std::string, std::vector<std::string>>> v);
|
10
|
+
void assertEqual(string std::sExpected, std::string sResult);
|
11
11
|
|
12
12
|
void setup() {
|
13
13
|
ssm.clear();
|
14
14
|
|
15
15
|
//@ssm[Set[1, 2]] = "Foo"
|
16
|
-
vector<string> s1;
|
16
|
+
std::vector<std::string> s1;
|
17
17
|
s1.push_back("1");
|
18
18
|
s1.push_back("2");
|
19
19
|
ssm.put(s1, "Foo");
|
20
20
|
|
21
21
|
//@ssm[Set["fizz", "fazz"]] = "Bar"
|
22
|
-
vector<string> s2;
|
22
|
+
std::vector<std::string> s2;
|
23
23
|
s2.push_back("fizz");
|
24
24
|
s2.push_back("fazz");
|
25
25
|
ssm.put(s2, "Bar");
|
26
26
|
|
27
27
|
//@ssm[Set[:foo, :bar]] = "Baz"
|
28
|
-
vector<string> s3;
|
28
|
+
std::vector<std::string> s3;
|
29
29
|
s3.push_back(":foo");
|
30
30
|
s3.push_back(":bar");
|
31
31
|
ssm.put(s3, "Baz");
|
32
32
|
|
33
33
|
//@ssm[Set[:foo, :bar, :baz]] = "Bang"
|
34
|
-
vector<string> s4;
|
34
|
+
std::vector<std::string> s4;
|
35
35
|
s4.push_back(":foo");
|
36
36
|
s4.push_back(":bar");
|
37
37
|
s4.push_back(":baz");
|
38
38
|
ssm.put(s4, "Bang");
|
39
39
|
|
40
40
|
//@ssm[Set[:bip, :bop, :blip]] = "Qux"
|
41
|
-
vector<string> s5;
|
41
|
+
std::vector<std::string> s5;
|
42
42
|
s5.push_back(":bip");
|
43
43
|
s5.push_back(":bop");
|
44
44
|
s5.push_back(":blip");
|
45
45
|
ssm.put(s5, "Qux");
|
46
46
|
|
47
47
|
//@ssm[Set[:bip, :bop]] = "Thram"
|
48
|
-
vector<string> s6;
|
48
|
+
std::vector<std::string> s6;
|
49
49
|
s6.push_back(":bip");
|
50
50
|
s6.push_back(":bop");
|
51
51
|
ssm.put(s6, "Thram");
|
52
52
|
}
|
53
53
|
|
54
54
|
void testEqualKeys() {
|
55
|
-
cout << "testEqualKeys" << endl;
|
55
|
+
std::cout << "testEqualKeys" << std::endl;
|
56
56
|
|
57
57
|
//assert_equal [["Foo", Set[1, 2]]], @ssm.get(Set[1, 2])
|
58
|
-
vector<string> k1;
|
58
|
+
std::vector<std::string> k1;
|
59
59
|
k1.push_back("1");
|
60
60
|
k1.push_back("2");
|
61
61
|
assertEqual("[[Foo, Set[1, 2]]]", toString(ssm.get_kv(k1)));
|
62
62
|
|
63
63
|
//assert_equal [["Bar", Set["fizz", "fazz"]]], @ssm.get(Set["fizz", "fazz"])
|
64
|
-
vector<string> k2;
|
64
|
+
std::vector<std::string> k2;
|
65
65
|
k2.push_back("fizz");
|
66
66
|
k2.push_back("fazz");
|
67
67
|
assertEqual("[[Bar, Set[fizz, fazz]]]", toString(ssm.get_kv(k2)));
|
68
68
|
|
69
|
-
cout << endl;
|
69
|
+
std::cout << std::endl;
|
70
70
|
}
|
71
71
|
|
72
72
|
void testSubsetKeys() {
|
73
|
-
cout << "testSubsetKeys" << endl;
|
73
|
+
std::cout << "testSubsetKeys" << std::endl;
|
74
74
|
|
75
75
|
//assert_equal [["Foo", Set[1, 2]]], @ssm.get(Set[1, 2, "fuzz"])
|
76
|
-
vector<string> k1;
|
76
|
+
std::vector<std::string> k1;
|
77
77
|
k1.push_back("1");
|
78
78
|
k1.push_back("2");
|
79
79
|
k1.push_back("fuzz");
|
80
80
|
assertEqual("[[Foo, Set[1, 2]]]", toString(ssm.get_kv(k1)));
|
81
81
|
|
82
82
|
//assert_equal [["Bar", Set["fizz", "fazz"]]], @ssm.get(Set["fizz", "fazz", 3])
|
83
|
-
vector<string> k2;
|
83
|
+
std::vector<std::string> k2;
|
84
84
|
k2.push_back("fizz");
|
85
85
|
k2.push_back("fazz");
|
86
86
|
k2.push_back("3");
|
87
87
|
assertEqual("[[Bar, Set[fizz, fazz]]]", toString(ssm.get_kv(k2)));
|
88
88
|
|
89
|
-
cout << endl;
|
89
|
+
std::cout << std::endl;
|
90
90
|
}
|
91
91
|
|
92
92
|
void testSupersetKeys() {
|
93
|
-
cout << "testSupersetKeys" << endl;
|
93
|
+
std::cout << "testSupersetKeys" << std::endl;
|
94
94
|
|
95
95
|
//assert_equal [], @ssm.get(Set[1])
|
96
|
-
vector<string> k1;
|
96
|
+
std::vector<std::string> k1;
|
97
97
|
k1.push_back("1");
|
98
98
|
assertEqual("[]", toString(ssm.get_kv(k1)));
|
99
99
|
|
100
100
|
//assert_equal [], @ssm.get(Set[2])
|
101
|
-
vector<string> k2;
|
101
|
+
std::vector<std::string> k2;
|
102
102
|
k2.push_back("2");
|
103
103
|
assertEqual("[]", toString(ssm.get_kv(k2)));
|
104
104
|
|
105
105
|
//assert_equal [], @ssm.get(Set["fizz"])
|
106
|
-
vector<string> k3;
|
106
|
+
std::vector<std::string> k3;
|
107
107
|
k3.push_back("fizz");
|
108
108
|
assertEqual("[]", toString(ssm.get_kv(k3)));
|
109
109
|
|
110
110
|
//assert_equal [], @ssm.get(Set["fazz"])
|
111
|
-
vector<string> k4;
|
111
|
+
std::vector<std::string> k4;
|
112
112
|
k4.push_back("fazz");
|
113
113
|
assertEqual("[]", toString(ssm.get_kv(k4)));
|
114
114
|
|
115
|
-
cout << endl;
|
115
|
+
std::cout << std::endl;
|
116
116
|
}
|
117
117
|
|
118
118
|
void testDisjointKeys() {
|
119
|
-
cout << "testDisjointKeys" << endl;
|
119
|
+
std::cout << "testDisjointKeys" << std::endl;
|
120
120
|
|
121
121
|
//assert_equal [], @ssm.get(Set[3, 4])
|
122
|
-
vector<string> k1;
|
122
|
+
std::vector<std::string> k1;
|
123
123
|
k1.push_back("3");
|
124
124
|
k1.push_back("4");
|
125
125
|
assertEqual("[]", toString(ssm.get_kv(k1)));
|
126
126
|
|
127
127
|
//assert_equal [], @ssm.get(Set["fuzz", "frizz"])
|
128
|
-
vector<string> k2;
|
128
|
+
std::vector<std::string> k2;
|
129
129
|
k2.push_back("fuzz");
|
130
130
|
k2.push_back("frizz");
|
131
131
|
assertEqual("[]", toString(ssm.get_kv(k2)));
|
132
132
|
|
133
133
|
//assert_equal [], @ssm.get(Set["gran", 15])
|
134
|
-
vector<string> k3;
|
134
|
+
std::vector<std::string> k3;
|
135
135
|
k3.push_back("gran");
|
136
136
|
k3.push_back("15");
|
137
137
|
assertEqual("[]", toString(ssm.get_kv(k3)));
|
138
138
|
|
139
|
-
cout << endl;
|
139
|
+
std::cout << std::endl;
|
140
140
|
}
|
141
141
|
|
142
142
|
void testSemiDisjointKeys() {
|
143
|
-
cout << "testSemiDisjointKeys" << endl;
|
143
|
+
std::cout << "testSemiDisjointKeys" << std::endl;
|
144
144
|
|
145
145
|
//assert_equal [], @ssm.get(Set[2, 3])
|
146
|
-
vector<string> k1;
|
146
|
+
std::vector<std::string> k1;
|
147
147
|
k1.push_back("2");
|
148
148
|
k1.push_back("3");
|
149
149
|
assertEqual("[]", toString(ssm.get_kv(k1)));
|
150
150
|
|
151
151
|
//assert_equal [], @ssm.get(Set["fizz", "fuzz"])
|
152
|
-
vector<string> k2;
|
152
|
+
std::vector<std::string> k2;
|
153
153
|
k2.push_back("fizz");
|
154
154
|
k2.push_back("fuzz");
|
155
155
|
assertEqual("[]", toString(ssm.get_kv(k2)));
|
156
156
|
|
157
157
|
//assert_equal [], @ssm.get(Set[1, "fazz"])
|
158
|
-
vector<string> k3;
|
158
|
+
std::vector<std::string> k3;
|
159
159
|
k3.push_back("1");
|
160
160
|
k3.push_back("fazz");
|
161
161
|
assertEqual("[]", toString(ssm.get_kv(k3)));
|
162
162
|
|
163
|
-
cout << endl;
|
163
|
+
std::cout << std::endl;
|
164
164
|
}
|
165
165
|
|
166
166
|
void testEmptyKeySet() {
|
167
|
-
cout << "testEmptyKeySet" << endl;
|
167
|
+
std::cout << "testEmptyKeySet" << std::endl;
|
168
168
|
|
169
169
|
//assert_raises(ArgumentError) {@ssm[Set[]] = "Fail"}
|
170
|
-
vector<string> s1;
|
170
|
+
std::vector<std::string> s1;
|
171
171
|
try {
|
172
172
|
ssm.put(s1, "Fail");
|
173
173
|
}
|
@@ -177,19 +177,19 @@ void testEmptyKeySet() {
|
|
177
177
|
}
|
178
178
|
|
179
179
|
void testEmptyKeyGet() {
|
180
|
-
cout << "testEmptyKeyGet" << endl;
|
180
|
+
std::cout << "testEmptyKeyGet" << std::endl;
|
181
181
|
|
182
182
|
//assert_equal [], @ssm.get(Set[])
|
183
|
-
vector<string> k1;
|
183
|
+
std::vector<std::string> k1;
|
184
184
|
assertEqual("[]", toString(ssm.get_kv(k1)));
|
185
185
|
|
186
|
-
cout << endl;
|
186
|
+
std::cout << std::endl;
|
187
187
|
}
|
188
188
|
void testMultipleSubsets() {
|
189
|
-
cout << "testMultipleSubsets" << endl;
|
189
|
+
std::cout << "testMultipleSubsets" << std::endl;
|
190
190
|
|
191
191
|
//assert_equal [["Foo", Set[1, 2]], ["Bar", Set["fizz", "fazz"]]], @ssm.get(Set[1, 2, "fizz", "fazz"])
|
192
|
-
vector<string> k1;
|
192
|
+
std::vector<std::string> k1;
|
193
193
|
k1.push_back("1");
|
194
194
|
k1.push_back("2");
|
195
195
|
k1.push_back("fizz");
|
@@ -197,7 +197,7 @@ void testMultipleSubsets() {
|
|
197
197
|
assertEqual("[[Foo, Set[1, 2]], [Bar, Set[fizz, fazz]]]", toString(ssm.get_kv(k1)));
|
198
198
|
|
199
199
|
//assert_equal [["Foo", Set[1, 2]], ["Bar", Set["fizz", "fazz"]]], @ssm.get(Set[1, 2, 3, "fizz", "fazz", "fuzz"])
|
200
|
-
vector<string> k2;
|
200
|
+
std::vector<std::string> k2;
|
201
201
|
k2.push_back("1");
|
202
202
|
k2.push_back("2");
|
203
203
|
k2.push_back("3");
|
@@ -207,80 +207,80 @@ void testMultipleSubsets() {
|
|
207
207
|
assertEqual("[[Foo, Set[1, 2]], [Bar, Set[fizz, fazz]]]", toString(ssm.get_kv(k2)));
|
208
208
|
|
209
209
|
//assert_equal [["Baz", Set[:foo, :bar]]], @ssm.get(Set[:foo, :bar])
|
210
|
-
vector<string> k3;
|
210
|
+
std::vector<std::string> k3;
|
211
211
|
k3.push_back(":foo");
|
212
212
|
k3.push_back(":bar");
|
213
213
|
assertEqual("[[Baz, Set[:foo, :bar]]]", toString(ssm.get_kv(k3)));
|
214
214
|
|
215
215
|
//assert_equal [["Baz", Set[:foo, :bar]], ["Bang", Set[:foo, :bar, :baz]]], @ssm.get(Set[:foo, :bar, :baz])
|
216
|
-
vector<string> k4;
|
216
|
+
std::vector<std::string> k4;
|
217
217
|
k4.push_back(":foo");
|
218
218
|
k4.push_back(":bar");
|
219
219
|
k4.push_back(":baz");
|
220
220
|
assertEqual("[[Baz, Set[:foo, :bar]], [Bang, Set[:foo, :bar, :baz]]]", toString(ssm.get_kv(k4)));
|
221
221
|
|
222
|
-
cout << endl;
|
222
|
+
std::cout << std::endl;
|
223
223
|
}
|
224
224
|
void testBracketBracket() {
|
225
|
-
cout << "testBracketBracket" << endl;
|
225
|
+
std::cout << "testBracketBracket" << std::endl;
|
226
226
|
|
227
227
|
//assert_equal ["Foo"], @ssm[Set[1, 2, "fuzz"]]
|
228
|
-
vector<string> k1;
|
228
|
+
std::vector<std::string> k1;
|
229
229
|
k1.push_back("1");
|
230
230
|
k1.push_back("2");
|
231
231
|
k1.push_back("fuzz");
|
232
232
|
assertEqual("[Foo]", toString(ssm.get_v(k1)));
|
233
233
|
|
234
234
|
//assert_equal ["Baz", "Bang"], @ssm[Set[:foo, :bar, :baz]]
|
235
|
-
vector<string> k2;
|
235
|
+
std::vector<std::string> k2;
|
236
236
|
k2.push_back(":foo");
|
237
237
|
k2.push_back(":bar");
|
238
238
|
k2.push_back(":baz");
|
239
239
|
assertEqual("[Baz, Bang]", toString(ssm.get_v(k2)));
|
240
240
|
|
241
|
-
cout << endl;
|
241
|
+
std::cout << std::endl;
|
242
242
|
}
|
243
243
|
|
244
244
|
void testKeyOrder() {
|
245
|
-
cout << "testEqualKeys" << endl;
|
245
|
+
std::cout << "testEqualKeys" << std::endl;
|
246
246
|
|
247
247
|
//assert_equal [["Foo", Set[1, 2]]], @ssm.get(Set[2, 1])
|
248
|
-
vector<string> k1;
|
248
|
+
std::vector<std::string> k1;
|
249
249
|
k1.push_back("2");
|
250
250
|
k1.push_back("1");
|
251
251
|
assertEqual("[[Foo, Set[1, 2]]]", toString(ssm.get_kv(k1)));
|
252
252
|
|
253
|
-
cout << endl;
|
253
|
+
std::cout << std::endl;
|
254
254
|
}
|
255
255
|
|
256
256
|
void testOrderPreserved() {
|
257
|
-
cout << "testOrderPreserved" << endl;
|
257
|
+
std::cout << "testOrderPreserved" << std::endl;
|
258
258
|
//@ssm[Set[10, 11, 12]] = 1
|
259
|
-
vector<string> s1;
|
259
|
+
std::vector<std::string> s1;
|
260
260
|
s1.push_back("10");
|
261
261
|
s1.push_back("11");
|
262
262
|
s1.push_back("12");
|
263
263
|
ssm.put(s1, "1");
|
264
264
|
|
265
265
|
//@ssm[Set[10, 11]] = 2
|
266
|
-
vector<string> s2;
|
266
|
+
std::vector<std::string> s2;
|
267
267
|
s2.push_back("10");
|
268
268
|
s2.push_back("11");
|
269
269
|
ssm.put(s2, "2");
|
270
270
|
|
271
271
|
//@ssm[Set[11]] = 3
|
272
|
-
vector<string> s3;
|
272
|
+
std::vector<std::string> s3;
|
273
273
|
s3.push_back("11");
|
274
274
|
ssm.put(s3, "3");
|
275
275
|
|
276
276
|
//@ssm[Set[11, 12]] = 4
|
277
|
-
vector<string> s4;
|
277
|
+
std::vector<std::string> s4;
|
278
278
|
s4.push_back("11");
|
279
279
|
s4.push_back("12");
|
280
280
|
ssm.put(s4, "4");
|
281
281
|
|
282
282
|
//@ssm[Set[9, 10, 11, 12, 13]] = 5
|
283
|
-
vector<string> s5;
|
283
|
+
std::vector<std::string> s5;
|
284
284
|
s5.push_back("9");
|
285
285
|
s5.push_back("10");
|
286
286
|
s5.push_back("11");
|
@@ -289,13 +289,13 @@ void testOrderPreserved() {
|
|
289
289
|
ssm.put(s5, "5");
|
290
290
|
|
291
291
|
//@ssm[Set[10, 13]] = 6
|
292
|
-
vector<string> s6;
|
292
|
+
std::vector<std::string> s6;
|
293
293
|
s6.push_back("10");
|
294
294
|
s6.push_back("13");
|
295
295
|
ssm.put(s6, "6");
|
296
296
|
|
297
297
|
//assert_equal([[1, Set[10, 11, 12]], [2, Set[10, 11]], [3, Set[11]], [4, Set[11, 12]], [5, Set[9, 10, 11, 12, 13]], [6, Set[10, 13]]], @ssm.get(Set[9, 10, 11, 12, 13]))
|
298
|
-
vector<string> k1;
|
298
|
+
std::vector<std::string> k1;
|
299
299
|
k1.push_back("9");
|
300
300
|
k1.push_back("10");
|
301
301
|
k1.push_back("11");
|
@@ -303,36 +303,36 @@ void testOrderPreserved() {
|
|
303
303
|
k1.push_back("13");
|
304
304
|
assertEqual("[[1, Set[10, 11, 12]], [2, Set[10, 11]], [3, Set[11]], [4, Set[11, 12]], [5, Set[9, 10, 11, 12, 13]], [6, Set[10, 13]]]", toString(ssm.get_kv(k1)));
|
305
305
|
|
306
|
-
cout << endl;
|
306
|
+
std::cout << std::endl;
|
307
307
|
}
|
308
308
|
void testMultipleEqualValues() {
|
309
|
-
cout << "testMultipleEqualValues" << endl;
|
309
|
+
std::cout << "testMultipleEqualValues" << std::endl;
|
310
310
|
//@ssm[Set[11, 12]] = 1
|
311
|
-
vector<string> s1;
|
311
|
+
std::vector<std::string> s1;
|
312
312
|
s1.push_back("11");
|
313
313
|
s1.push_back("12");
|
314
314
|
ssm.put(s1, "1");
|
315
315
|
|
316
316
|
//@ssm[Set[12, 13]] = 2
|
317
|
-
vector<string> s2;
|
317
|
+
std::vector<std::string> s2;
|
318
318
|
s2.push_back("12");
|
319
319
|
s2.push_back("13");
|
320
320
|
ssm.put(s2, "2");
|
321
321
|
|
322
322
|
//@ssm[Set[13, 14]] = 1
|
323
|
-
vector<string> s3;
|
323
|
+
std::vector<std::string> s3;
|
324
324
|
s3.push_back("13");
|
325
325
|
s3.push_back("14");
|
326
326
|
ssm.put(s3, "1");
|
327
327
|
|
328
328
|
//@ssm[Set[14, 15]] = 1
|
329
|
-
vector<string> s4;
|
329
|
+
std::vector<std::string> s4;
|
330
330
|
s4.push_back("14");
|
331
331
|
s4.push_back("15");
|
332
332
|
ssm.put(s4, "1");
|
333
333
|
|
334
334
|
//assert_equal([[1, Set[11, 12]], [2, Set[12, 13]], [1, Set[13, 14]], [1, Set[14, 15]]], @ssm.get(Set[11, 12, 13, 14, 15]))
|
335
|
-
vector<string> k1;
|
335
|
+
std::vector<std::string> k1;
|
336
336
|
k1.push_back("11");
|
337
337
|
k1.push_back("12");
|
338
338
|
k1.push_back("13");
|
@@ -340,20 +340,20 @@ void testMultipleEqualValues() {
|
|
340
340
|
k1.push_back("15");
|
341
341
|
assertEqual("[[1, Set[11, 12]], [2, Set[12, 13]], [1, Set[13, 14]], [1, Set[14, 15]]]", toString(ssm.get_kv(k1)));
|
342
342
|
|
343
|
-
cout << endl;
|
343
|
+
std::cout << std::endl;
|
344
344
|
}
|
345
345
|
|
346
346
|
int main()
|
347
347
|
{
|
348
|
-
vector<string> s1;
|
348
|
+
std::vector<std::string> s1;
|
349
349
|
s1.push_back("1");
|
350
350
|
s1.push_back("2");
|
351
351
|
|
352
|
-
vector<string> s2;
|
352
|
+
std::vector<std::string> s2;
|
353
353
|
s2.push_back("2");
|
354
354
|
s2.push_back("3");
|
355
355
|
|
356
|
-
vector<string> s3;
|
356
|
+
std::vector<std::string> s3;
|
357
357
|
s3.push_back("3");
|
358
358
|
s3.push_back("4");
|
359
359
|
|
@@ -361,16 +361,16 @@ int main()
|
|
361
361
|
ssm.put(s2, "value2");
|
362
362
|
ssm.put(s3, "value3");
|
363
363
|
|
364
|
-
vector<string> s4;
|
364
|
+
std::vector<std::string> s4;
|
365
365
|
s4.push_back("1");
|
366
366
|
s4.push_back("2");
|
367
367
|
s4.push_back("3");
|
368
368
|
|
369
|
-
vector<pair<string, vector<string> > > fetched(ssm.get_kv(s4));
|
369
|
+
std::vector<std::pair<string, std::vector<std::string> > > fetched(ssm.get_kv(s4));
|
370
370
|
|
371
|
-
cout << "PRINTING RESULTS:" << endl;
|
371
|
+
std::cout << "PRINTING RESULTS:" << std::endl;
|
372
372
|
for (size_t i = 0, S = fetched.size(); i < S; ++i) {
|
373
|
-
cout << fetched[i].first << endl;
|
373
|
+
std::cout << fetched[i].first << std::endl;
|
374
374
|
}
|
375
375
|
|
376
376
|
Subset_Map<string, string> ssm2;
|
@@ -378,33 +378,33 @@ int main()
|
|
378
378
|
ssm2.put(s2, "bar");
|
379
379
|
ssm2.put(s4, "hux");
|
380
380
|
|
381
|
-
vector<pair<string, vector<string> > > fetched2(ssm2.get_kv(s4));
|
381
|
+
std::vector<std::pair<string, std::vector<std::string> > > fetched2(ssm2.get_kv(s4));
|
382
382
|
|
383
|
-
cout << endl << "PRINTING RESULTS:" << endl;
|
383
|
+
std::cout << std::endl << "PRINTING RESULTS:" << std::endl;
|
384
384
|
for (size_t i = 0, S = fetched2.size(); i < S; ++i) {
|
385
|
-
cout << fetched2[i].first << endl;
|
385
|
+
std::cout << fetched2[i].first << std::endl;
|
386
386
|
}
|
387
387
|
|
388
|
-
cout << "TRYING ON A SELECTOR-LIKE OBJECT" << endl;
|
388
|
+
std::cout << "TRYING ON A SELECTOR-LIKE OBJECT" << std::endl;
|
389
389
|
|
390
390
|
Subset_Map<string, string> sel_ssm;
|
391
|
-
vector<string> target;
|
391
|
+
std::vector<std::string> target;
|
392
392
|
target.push_back("desk");
|
393
393
|
target.push_back(".wood");
|
394
394
|
|
395
|
-
vector<string> actual;
|
395
|
+
std::vector<std::string> actual;
|
396
396
|
actual.push_back("desk");
|
397
397
|
actual.push_back(".wood");
|
398
398
|
actual.push_back(".mine");
|
399
399
|
|
400
400
|
sel_ssm.put(target, "has-aquarium");
|
401
|
-
vector<pair<string, vector<string> > > fetched3(sel_ssm.get_kv(actual));
|
402
|
-
cout << "RESULTS:" << endl;
|
401
|
+
std::vector<std::pair<string, std::vector<std::string> > > fetched3(sel_ssm.get_kv(actual));
|
402
|
+
std::cout << "RESULTS:" << std::endl;
|
403
403
|
for (size_t i = 0, S = fetched3.size(); i < S; ++i) {
|
404
|
-
cout << fetched3[i].first << endl;
|
404
|
+
std::cout << fetched3[i].first << std::endl;
|
405
405
|
}
|
406
406
|
|
407
|
-
cout << endl;
|
407
|
+
std::cout << std::endl;
|
408
408
|
|
409
409
|
// BEGIN PORTED RUBY TESTS FROM /test/sass/util/subset_map_test.rb
|
410
410
|
|
@@ -429,9 +429,9 @@ int main()
|
|
429
429
|
return 0;
|
430
430
|
}
|
431
431
|
|
432
|
-
string toString(vector<pair<string, vector<string>>> v)
|
432
|
+
string toString(std::vector<std::pair<string, std::vector<std::string>>> v)
|
433
433
|
{
|
434
|
-
stringstream buffer;
|
434
|
+
std::stringstream buffer;
|
435
435
|
buffer << "[";
|
436
436
|
for (size_t i = 0, S = v.size(); i < S; ++i) {
|
437
437
|
buffer << "[" << v[i].first;
|
@@ -451,9 +451,9 @@ string toString(vector<pair<string, vector<string>>> v)
|
|
451
451
|
return buffer.str();
|
452
452
|
}
|
453
453
|
|
454
|
-
string toString(vector<string> v)
|
454
|
+
string toString(std::vector<std::string> v)
|
455
455
|
{
|
456
|
-
stringstream buffer;
|
456
|
+
std::stringstream buffer;
|
457
457
|
buffer << "[";
|
458
458
|
for (size_t i = 0, S = v.size(); i < S; ++i) {
|
459
459
|
buffer << v[i];
|
@@ -466,7 +466,7 @@ string toString(vector<string> v)
|
|
466
466
|
}
|
467
467
|
|
468
468
|
void assertEqual(string sExpected, string sResult) {
|
469
|
-
cout << "Expected: " << sExpected << endl;
|
470
|
-
cout << "Result: " << sResult << endl;
|
469
|
+
std::cout << "Expected: " << sExpected << std::endl;
|
470
|
+
std::cout << "Result: " << sResult << std::endl;
|
471
471
|
assert(sExpected == sResult);
|
472
472
|
}
|