mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-15 11:04:49 +00:00
pybricksMicropython: implement appending imports
This implements appending compiled imported modules for the multi-mpy6 file format.
This commit is contained in:
committed by
David Lechner
parent
8b19ad5866
commit
be9272ca9c
@@ -3,6 +3,7 @@
|
||||
|
||||
import {
|
||||
FileNameValidationResult,
|
||||
findImportedModules,
|
||||
pythonFileExtension,
|
||||
pythonFileExtensionRegex,
|
||||
validateFileName,
|
||||
@@ -76,3 +77,46 @@ describe('validateFileName', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('findImportedModules', async () => {
|
||||
const script = `
|
||||
import a
|
||||
import b, c
|
||||
import d.d
|
||||
import e.e as e
|
||||
import f.f as f, g
|
||||
from h import x
|
||||
from h import x as y
|
||||
from i import (x, y)
|
||||
from i import (x as y, z)
|
||||
from j import *
|
||||
from . import x
|
||||
from . import x as y
|
||||
from .r import x
|
||||
from ..r import x
|
||||
from ...r import x
|
||||
from ....r import x
|
||||
`;
|
||||
|
||||
const modules = findImportedModules(script);
|
||||
|
||||
expect(modules).toEqual(
|
||||
new Set([
|
||||
'a',
|
||||
'b',
|
||||
'c',
|
||||
'd.d',
|
||||
'e.e',
|
||||
'f.f',
|
||||
'g',
|
||||
'h',
|
||||
'i',
|
||||
'j',
|
||||
'.',
|
||||
'.r',
|
||||
'..r',
|
||||
'...r',
|
||||
'....r',
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user