File tree Expand file tree Collapse file tree
apps/client-e2e/src/tests/interactions
idl/test/client-e2e/notebooks
libs/parsing/index/src/lib/helpers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import { NotebookProblemsTrackRight } from './notebooks/notebook-problems-track-
3838import { NotebookCompletionBasic } from './notebooks/notebooks-completion-basic' ;
3939import { NotebooksInteractRight } from './notebooks/notebooks-interact-right' ;
4040import { NotebooksNoDuplicateRoutines } from './notebooks/notebooks-no-duplicate-routines' ;
41+ import { NotebooksNoUndefinedVars } from './notebooks/notebooks-no-undefined-vars' ;
4142import { BasicSymbolicLinks } from './symbolic-links/basic-symbolic-links' ;
4243import { BasicSymbolicLinksWithProblems } from './symbolic-links/basic-symbolic-links-with-problems' ;
4344import { InteractionSymbolicLinkProblemReporting } from './symbolic-links/interaction-symbolic-links-problem-reporting' ;
@@ -221,6 +222,11 @@ INTERACTIONS_RUNNER.addTest({
221222 fn : NotebookImpliedPrintProblemReporting ,
222223} ) ;
223224
225+ INTERACTIONS_RUNNER . addTest ( {
226+ name : 'Notebooks properly inherit variables' ,
227+ fn : NotebooksNoUndefinedVars ,
228+ } ) ;
229+
224230INTERACTIONS_RUNNER . addTest ( {
225231 name : 'Detect duplicate globals from two PRO files' ,
226232 fn : DuplicateGlobals ,
Original file line number Diff line number Diff line change 1+ import { GetExtensionPath , Sleep } from '@idl/shared' ;
2+ import { OpenNotebookInVSCode } from '@idl/vscode/shared' ;
3+ import expect from 'expect' ;
4+ import * as vscode from 'vscode' ;
5+
6+ import { CLIENT_E2E_CONFIG } from '../../client-e2e-config.interface' ;
7+ import { RunnerFunction } from '../../runner.interface' ;
8+
9+ /**
10+ * Verifies our variables are defined
11+ */
12+ export const NotebooksNoUndefinedVars : RunnerFunction = async ( init ) => {
13+ const doc = await OpenNotebookInVSCode (
14+ GetExtensionPath ( 'idl/test/client-e2e/notebooks/no-undefined-vars.idlnb' )
15+ ) ;
16+
17+ // short pause
18+ await Sleep ( CLIENT_E2E_CONFIG . DELAYS . PROBLEMS_NOTEBOOK ) ;
19+
20+ // no problems in first cell
21+ expect (
22+ vscode . languages . getDiagnostics ( doc . cellAt ( 0 ) . document . uri ) . length
23+ ) . toEqual ( 0 ) ;
24+
25+ // no problems in second cell
26+ expect (
27+ vscode . languages . getDiagnostics ( doc . cellAt ( 1 ) . document . uri ) . length
28+ ) . toEqual ( 0 ) ;
29+ } ;
Original file line number Diff line number Diff line change 1+ {
2+ "version": "2.0.0",
3+ "cells": [
4+ {
5+ "type": "code",
6+ "content": [
7+ "e = envi(/headless)"
8+ ],
9+ "metadata": {},
10+ "outputs": []
11+ },
12+ {
13+ "type": "code",
14+ "content": [
15+ "print, e.task_names, /implied_print"
16+ ],
17+ "metadata": {},
18+ "outputs": []
19+ }
20+ ]
21+ }
Original file line number Diff line number Diff line change @@ -85,7 +85,9 @@ export function PopulateNotebookVariables(
8585 */
8686 const otherVarName = otherVars [ j ] ;
8787
88- // inherit variable
88+ /**
89+ * Inherit variable that we detect
90+ */
8991 if ( otherVarName in ourMain ) {
9092 /**
9193 * Check if we need to set the variable (it hasnt been processed already)
@@ -109,13 +111,18 @@ export function PopulateNotebookVariables(
109111 weSet [ otherVarName ] = undefined ;
110112 }
111113
112- // if we arent defined, inherit
114+ // if we arent defined in our cell , inherit
113115 if ( ! ourMain [ otherVarName ] . meta . isDefined ) {
114116 ourMain [ otherVarName ] . meta . isDefined =
115117 otherMain [ otherVarName ] . meta . isDefined ;
116118 ourMain [ otherVarName ] . meta . type = otherMain [ otherVarName ] . meta . type ;
117119 ourMain [ otherVarName ] . meta . isStaticClass =
118120 otherMain [ otherVarName ] . meta . isStaticClass ;
121+
122+ // if the other variable is defined, then set as we dont reset for post-processing
123+ if ( otherMain [ otherVarName ] . meta . isDefined ) {
124+ ourMain [ otherVarName ] . meta . canReset = false ;
125+ }
119126 }
120127 } else {
121128 // copy
You can’t perform that action at this time.
0 commit comments