Skip to content

Commit

Permalink
add getItemType() to SassListItem to prevent a large count od instanceof
Browse files Browse the repository at this point in the history
  • Loading branch information
volker committed Jul 19, 2023
1 parent ded5b81 commit a58c326
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void testMultiplyWithUnitInfirstOperand() {
operand3);
Assert.assertEquals(6, result.getIntegerValue());
Assert.assertEquals(SCSSLexicalUnit.SAC_CENTIMETER,
result.getLexicalUnitType());
result.getItemType());
}

@Test
Expand All @@ -90,7 +90,7 @@ public void testMultiplyWithUnitInSecondOperand() {
operand3cm);
Assert.assertEquals(6, result.getIntegerValue());
Assert.assertEquals(SCSSLexicalUnit.SAC_CENTIMETER,
result.getLexicalUnitType());
result.getItemType());
}

@Test
Expand All @@ -99,7 +99,7 @@ public void testDivideWithSameUnit() {
LexicalUnitImpl result = evaluate(operand4cm, operatorDivide,
operand2cm);
Assert.assertEquals(2, result.getIntegerValue());
Assert.assertEquals(SCSSLexicalUnit.SAC_REAL, result.getLexicalUnitType());
Assert.assertEquals(SCSSLexicalUnit.SAC_REAL, result.getItemType());
}

@Test
Expand All @@ -108,7 +108,7 @@ public void testDivideDenominatorWithoutUnit() {
LexicalUnitImpl result = evaluate(operand4cm, operatorDivide, operand2);
Assert.assertEquals(2, result.getIntegerValue());
Assert.assertEquals(SCSSLexicalUnit.SAC_CENTIMETER,
result.getLexicalUnitType());
result.getItemType());
}

@Test(expected = ParseException.class)
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/inet/sass/testcases/scss/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void testParser() throws URISyntaxException, IOException {
Assert.assertEquals( 2, mixinDefNode1.getArglist().size() );
Assert.assertEquals( "thickness", mixinDefNode1.getArglist().get( 0 ).getName() );
Assert.assertEquals( "radius", mixinDefNode1.getArglist().get( 1 ).getName() );
Assert.assertEquals( SCSSLexicalUnit.SAC_PIXEL, mixinDefNode1.getArglist().get( 1 ).getExpr().getContainedValue().getLexicalUnitType() );
Assert.assertEquals( SCSSLexicalUnit.SAC_PIXEL, mixinDefNode1.getArglist().get( 1 ).getExpr().getContainedValue().getItemType() );
Assert.assertEquals( 3f, mixinDefNode1.getArglist().get( 1 ).getExpr().getContainedValue().getDoubleValue(), 0f );

Assert.assertEquals( 4, mixinDefNode1.getChildren().size() );
Expand All @@ -60,7 +60,7 @@ public void testParser() throws URISyntaxException, IOException {
MixinNode mixinNode0MainBlock = (MixinNode)mainBlockNode.getChildren().get( 0 );
Assert.assertEquals( "rounded-borders", mixinNode0MainBlock.getName() );
Assert.assertEquals( "mixinVar", mixinNode0MainBlock.getArglist().get( 0 ).getContainedValue().getStringValue() );
Assert.assertEquals( LexicalUnitImpl.SCSS_VARIABLE, mixinNode0MainBlock.getArglist().get( 0 ).getContainedValue().getLexicalUnitType() );
Assert.assertEquals( LexicalUnitImpl.SCSS_VARIABLE, mixinNode0MainBlock.getArglist().get( 0 ).getContainedValue().getItemType() );
MixinNode mixinNOde1MainBlock = (MixinNode)mainBlockNode.getChildren().get( 1 );
Assert.assertEquals( "font-settings", mixinNOde1MainBlock.getName() );
Assert.assertTrue( mixinNOde1MainBlock.getArglist().size() == 0 );
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/com/inet/sass/testcases/scss/Variables.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,34 @@ public void testParser() throws IOException, URISyntaxException {
Assert.assertEquals( 3, blockNode1.getChildren().size() );
RuleNode ruleNode1Block1 = (RuleNode)blockNode1.getChildren().get( 2 );
Assert.assertEquals( "border-color", ruleNode1Block1.getVariable().toString() );
Assert.assertEquals( SCSSLexicalUnit.SCSS_VARIABLE, ruleNode1Block1.getValue().getContainedValue().getLexicalUnitType() );
Assert.assertEquals( SCSSLexicalUnit.SCSS_VARIABLE, ruleNode1Block1.getValue().getContainedValue().getItemType() );
Assert.assertEquals( "blue", ruleNode1Block1.getValue().getContainedValue().getStringValue() );

RuleNode ruleNode2Block1 = (RuleNode)blockNode1.getChildren().get( 2 );
Assert.assertEquals( "border-color", ruleNode2Block1.getVariable().toString() );
Assert.assertEquals( SCSSLexicalUnit.SCSS_VARIABLE, ruleNode2Block1.getValue().getContainedValue().getLexicalUnitType() );
Assert.assertEquals( SCSSLexicalUnit.SCSS_VARIABLE, ruleNode2Block1.getValue().getContainedValue().getItemType() );
Assert.assertEquals( "blue", ruleNode2Block1.getValue().getContainedValue().getStringValue() );

BlockNode blockNode2 = (BlockNode)root.getChildren().get( 6 );
RuleNode ruleNode1Block2 = (RuleNode)blockNode2.getChildren().get( 0 );
Assert.assertEquals( "padding", ruleNode1Block2.getVariable().toString() );
Assert.assertEquals( SCSSLexicalUnit.SCSS_VARIABLE, ruleNode1Block2.getValue().getContainedValue().getLexicalUnitType() );
Assert.assertEquals( SCSSLexicalUnit.SCSS_VARIABLE, ruleNode1Block2.getValue().getContainedValue().getItemType() );
Assert.assertEquals( "margin", ruleNode1Block2.getValue().getContainedValue().getStringValue() );

RuleNode ruleNode2Block2 = (RuleNode)blockNode2.getChildren().get( 1 );
Assert.assertEquals( "margin", ruleNode2Block2.getVariable().toString() );
Assert.assertEquals( SCSSLexicalUnit.SCSS_VARIABLE, ruleNode2Block2.getValue().getContainedValue().getLexicalUnitType() );
Assert.assertEquals( SCSSLexicalUnit.SCSS_VARIABLE, ruleNode2Block2.getValue().getContainedValue().getItemType() );
Assert.assertEquals( "margin", ruleNode2Block2.getValue().getContainedValue().getStringValue() );

RuleNode ruleNode3Block2 = (RuleNode)blockNode2.getChildren().get( 2 );
Assert.assertEquals( "border-color", ruleNode3Block2.getVariable().toString() );
Assert.assertEquals( SCSSLexicalUnit.SCSS_VARIABLE, ruleNode1Block2.getValue().getContainedValue().getLexicalUnitType() );
Assert.assertEquals( SCSSLexicalUnit.SCSS_VARIABLE, ruleNode1Block2.getValue().getContainedValue().getItemType() );
Assert.assertEquals( "blue", ruleNode3Block2.getValue().getContainedValue().getStringValue() );

BlockNode blockNode3 = (BlockNode)root.getChildren().get( 7 );
RuleNode ruleNode1Block3 = (RuleNode)blockNode3.getChildren().get( 0 );
Assert.assertEquals( "background-image", ruleNode1Block3.getVariable().toString() );
Assert.assertEquals( SCSSLexicalUnit.SAC_FUNCTION, ruleNode1Block3.getValue().getContainedValue().getLexicalUnitType() );
Assert.assertEquals( SCSSLexicalUnit.SAC_FUNCTION, ruleNode1Block3.getValue().getContainedValue().getItemType() );
Assert.assertEquals( "url", ((LexicalUnitImpl)ruleNode1Block3.getValue()).getFunctionName() );
}

Expand Down

0 comments on commit a58c326

Please sign in to comment.