test: improve coverage
This commit is contained in:
@@ -277,6 +277,7 @@ function genNode(node: CodegenNode, context: CodegenContext) {
|
||||
genArrayExpression(node, context)
|
||||
break
|
||||
default:
|
||||
/* istanbul ignore next */
|
||||
__DEV__ &&
|
||||
assert(false, `unhandled codegen node type: ${(node as any).type}`)
|
||||
}
|
||||
@@ -399,7 +400,7 @@ function genFor(node: ForNode, context: CodegenContext) {
|
||||
}
|
||||
if (keyAlias) {
|
||||
if (!valueAlias) {
|
||||
push(`_`)
|
||||
push(`__value`)
|
||||
}
|
||||
push(`, `)
|
||||
genExpression(keyAlias, context)
|
||||
@@ -407,9 +408,9 @@ function genFor(node: ForNode, context: CodegenContext) {
|
||||
if (objectIndexAlias) {
|
||||
if (!keyAlias) {
|
||||
if (!valueAlias) {
|
||||
push(`_, __`)
|
||||
push(`__value, __key`)
|
||||
} else {
|
||||
push(`__`)
|
||||
push(`, __key`)
|
||||
}
|
||||
}
|
||||
push(`, `)
|
||||
@@ -447,12 +448,9 @@ function genObjectExpression(node: ObjectExpression, context: CodegenContext) {
|
||||
// value
|
||||
genExpression(value, context)
|
||||
if (i < properties.length - 1) {
|
||||
if (multilines) {
|
||||
push(`,`)
|
||||
newline()
|
||||
} else {
|
||||
push(`, `)
|
||||
}
|
||||
// will only reach this if it's multilines
|
||||
push(`,`)
|
||||
newline()
|
||||
}
|
||||
}
|
||||
multilines && deindent()
|
||||
|
||||
@@ -199,6 +199,7 @@ function pushNode(
|
||||
node: ChildNode
|
||||
): void {
|
||||
// ignore comments in production
|
||||
/* istanbul ignore next */
|
||||
if (!__DEV__ && node.type === NodeTypes.COMMENT) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ function createTransformContext(
|
||||
childIndex: 0,
|
||||
currentNode: null,
|
||||
replaceNode(node) {
|
||||
/* istanbul ignore if */
|
||||
if (__DEV__ && !context.currentNode) {
|
||||
throw new Error(`node being replaced is already removed.`)
|
||||
}
|
||||
@@ -97,6 +98,7 @@ function createTransformContext(
|
||||
: context.currentNode
|
||||
? context.childIndex
|
||||
: -1
|
||||
/* istanbul ignore if */
|
||||
if (__DEV__ && removalIndex < 0) {
|
||||
throw new Error(`node being removed is not a child of current parent`)
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ export function advancePositionWithMutation(
|
||||
}
|
||||
|
||||
export function assert(condition: boolean, msg?: string) {
|
||||
/* istanbul ignore if */
|
||||
if (!condition) {
|
||||
throw new Error(msg || `unexpected compiler condition`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user