-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #117 Parent selector (&) not supported in variable declaration
- Loading branch information
Showing
14 changed files
with
170 additions
and
22 deletions.
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
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
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
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
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
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
56 changes: 56 additions & 0 deletions
56
...test/java/org/sonar/css/parser/scss/ScssParentReferencingSelectorWithSpacingTreeTest.java
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,56 @@ | ||
/* | ||
* SonarQube CSS / SCSS / Less Analyzer | ||
* Copyright (C) 2013-2017 David RACODON | ||
* mailto: [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.css.parser.scss; | ||
|
||
import org.junit.Test; | ||
import org.sonar.css.parser.LexicalGrammar; | ||
import org.sonar.plugins.css.api.tree.scss.ScssParentReferencingSelectorTree; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
|
||
public class ScssParentReferencingSelectorWithSpacingTreeTest extends ScssTreeTest { | ||
|
||
public ScssParentReferencingSelectorWithSpacingTreeTest() { | ||
super(LexicalGrammar.SCSS_PARENT_REFERENCING_SELECTOR_WITH_SPACING); | ||
} | ||
|
||
@Test | ||
public void scssParentReferencingSelector() { | ||
checkParsed("&-bar", "-bar"); | ||
checkParsed(" &-bar", "-bar"); | ||
checkParsed("&bar", "bar"); | ||
checkParsed(" &bar", "bar"); | ||
} | ||
|
||
@Test | ||
public void notScssParentReferencingSelector() { | ||
checkNotParsed("&"); | ||
checkNotParsed("& bar"); | ||
} | ||
|
||
private void checkParsed(String toParse, String expectedIdentifier) { | ||
ScssParentReferencingSelectorTree tree = (ScssParentReferencingSelectorTree) parser().parse(toParse); | ||
assertThat(tree).isNotNull(); | ||
assertThat(tree.parent()).isNotNull(); | ||
assertThat(tree.append()).isNotNull(); | ||
assertThat(tree.text()).isEqualTo(expectedIdentifier); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...ontend/src/test/java/org/sonar/css/parser/scss/ScssParentSelectorWithSpacingTreeTest.java
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,47 @@ | ||
/* | ||
* SonarQube CSS / SCSS / Less Analyzer | ||
* Copyright (C) 2013-2017 David RACODON | ||
* mailto: [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.css.parser.scss; | ||
|
||
import org.junit.Test; | ||
import org.sonar.css.parser.LexicalGrammar; | ||
import org.sonar.plugins.css.api.tree.scss.ScssParentSelectorTree; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
|
||
public class ScssParentSelectorWithSpacingTreeTest extends ScssTreeTest { | ||
|
||
public ScssParentSelectorWithSpacingTreeTest() { | ||
super(LexicalGrammar.SCSS_PARENT_SELECTOR_WITH_SPACING); | ||
} | ||
|
||
@Test | ||
public void sscsParentSelector() { | ||
checkParsed("&"); | ||
checkParsed(" &"); | ||
} | ||
|
||
private void checkParsed(String toParse) { | ||
ScssParentSelectorTree tree = (ScssParentSelectorTree) parser().parse(toParse); | ||
assertThat(tree).isNotNull(); | ||
assertThat(tree.parentSelector()).isNotNull(); | ||
assertThat(tree.parentSelector().text()).isEqualTo("&"); | ||
} | ||
|
||
} |
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
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
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
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
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
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