Skip to content

Commit

Permalink
update sublimehq/Packages and update tests accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
jalil-salame committed May 6, 2024
1 parent b2a8ebe commit b62ffed
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/parsing/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,13 +493,13 @@ mod tests {

#[test]
fn load_raw() {
let comments_file: &str = "testdata/Packages/Go/Comments.tmPreferences";
let comments_file: &str = "testdata/Packages/Go/GoCommentRules.tmPreferences";
assert!(Path::new(comments_file).exists());

let r = RawMetadataEntry::load(comments_file);
assert!(r.is_ok());

let indent_file: &str = "testdata/Packages/Go/Indentation Rules.tmPreferences";
let indent_file: &str = "testdata/Packages/Go/Indents/GoIndent.tmPreferences";
assert!(Path::new(indent_file).exists());

let r = RawMetadataEntry::load(indent_file).unwrap();
Expand Down
55 changes: 33 additions & 22 deletions src/parsing/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,24 +757,35 @@ mod tests {
let ops1 = ops(&mut state, "module Bob::Wow::Troll::Five; 5; end", &ss);
let test_ops1 = vec![
(0, Push(Scope::new("source.ruby.rails").unwrap())),
(0, Push(Scope::new("meta.module.ruby").unwrap())),
(0, Push(Scope::new("keyword.control.module.ruby").unwrap())),
(0, Push(Scope::new("meta.namespace.ruby").unwrap())),
(0, Push(Scope::new("storage.type.namespace.ruby").unwrap())),
(
0,
Push(Scope::new("keyword.declaration.namespace.ruby").unwrap()),
),
(6, Pop(2)),
(6, Push(Scope::new("meta.module.ruby").unwrap())),
(7, Pop(1)),
(7, Push(Scope::new("meta.module.ruby").unwrap())),
(7, Push(Scope::new("entity.name.module.ruby").unwrap())),
(7, Push(Scope::new("meta.namespace.ruby").unwrap())),
(7, Push(Scope::new("entity.name.namespace.ruby").unwrap())),
(7, Push(Scope::new("support.other.namespace.ruby").unwrap())),
(10, Pop(1)),
(10, Push(Scope::new("punctuation.accessor.ruby").unwrap())),
(
10,
Push(Scope::new("punctuation.accessor.double-colon.ruby").unwrap()),
),
(12, Pop(1)),
];
assert_eq!(&ops1[0..test_ops1.len()], &test_ops1[..]);

let ops2 = ops(&mut state, "def lol(wow = 5)", &ss);
let test_ops2 = vec![
let test_ops2 = [
(0, Push(Scope::new("meta.function.ruby").unwrap())),
(0, Push(Scope::new("keyword.control.def.ruby").unwrap())),
(3, Pop(2)),
(0, Push(Scope::new("storage.type.function.ruby").unwrap())),
(
0,
Push(Scope::new("keyword.declaration.function.ruby").unwrap()),
),
(3, Pop(3)),
(3, Push(Scope::new("meta.function.ruby").unwrap())),
(4, Push(Scope::new("entity.name.function.ruby").unwrap())),
(7, Pop(1)),
Expand Down Expand Up @@ -829,6 +840,7 @@ mod tests {
test_stack.push(Scope::new("text.html.basic").unwrap());
test_stack.push(Scope::new("source.js.embedded.html").unwrap());
test_stack.push(Scope::new("source.js").unwrap());
test_stack.push(Scope::new("meta.string.js").unwrap());
test_stack.push(Scope::new("string.quoted.single.js").unwrap());
test_stack.push(Scope::new("source.ruby.rails.embedded.html").unwrap());
test_stack.push(Scope::new("meta.function.parameters.ruby").unwrap());
Expand Down Expand Up @@ -860,40 +872,39 @@ mod tests {
Push(Scope::new("keyword.operator.assignment.ruby").unwrap())
),
(5, Pop(1)),
(
6,
Push(Scope::new("string.unquoted.embedded.sql.ruby").unwrap())
),
(6, Push(Scope::new("meta.string.heredoc.ruby").unwrap())),
(6, Push(Scope::new("string.unquoted.heredoc.ruby").unwrap())),
(
6,
Push(Scope::new("punctuation.definition.string.begin.ruby").unwrap())
),
(12, Pop(2)),
(12, Pop(1)),
(12, Pop(1)),
(12, Push(Scope::new("meta.string.heredoc.ruby").unwrap())),
(12, Push(Scope::new("source.sql.embedded.ruby").unwrap())),
(12, Clear(ClearAmount::TopN(2))),
(
12,
Push(Scope::new("string.unquoted.embedded.sql.ruby").unwrap())
Push(Scope::new("punctuation.accessor.dot.ruby").unwrap())
),
(12, Push(Scope::new("text.sql.embedded.ruby").unwrap())),
(12, Clear(ClearAmount::TopN(2))),
(12, Push(Scope::new("punctuation.accessor.ruby").unwrap())),
(13, Pop(1)),
(18, Restore),
]
);

assert_eq!(ops(&mut state, "wow", &ss), vec![]);
assert_eq!(ops(&mut state, "wow", &ss), vec![(0, Restore)]);

assert_eq!(
ops(&mut state, "SQL", &ss),
vec![
(0, Pop(1)),
(0, Push(Scope::new("string.unquoted.heredoc.ruby").unwrap())),
(
0,
Push(Scope::new("punctuation.definition.string.end.ruby").unwrap())
),
(3, Pop(1)),
(3, Pop(1)),
(3, Pop(1)),
]
);
}
Expand Down Expand Up @@ -998,8 +1009,8 @@ mod tests {
let mut state1 = ParseState::new(syntax);
let mut state2 = ParseState::new(syntax);

assert_eq!(ops(&mut state1, "class Foo {", &ss).len(), 11);
assert_eq!(ops(&mut state2, "class Fooo {", &ss).len(), 11);
assert_eq!(ops(&mut state1, "class Foo {", &ss).len(), 12);
assert_eq!(ops(&mut state2, "class Fooo {", &ss).len(), 12);

assert_eq!(state1, state2);
ops(&mut state1, "}", &ss);
Expand Down
2 changes: 1 addition & 1 deletion src/parsing/syntax_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ mod tests {
.get_context(&syntax.context_ids()["main"])
.expect("#[cfg(test)]");
let count = syntax_definition::context_iter(&ps, main_context).count();
assert_eq!(count, 109);
assert_eq!(count, 168);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion testdata/Packages
Submodule Packages updated 382 files

0 comments on commit b62ffed

Please sign in to comment.