|
1 | 1 | import reducer from '../reducers';
|
2 | 2 | import { editCode } from '../reducers/code';
|
3 |
| -import { hasAssemblySymbolsSelector, hasMainFunctionSelector } from './index'; |
| 3 | +import { |
| 4 | + hasAssemblySymbolsSelector, |
| 5 | + hasLlvmIrSymbolsSelector, |
| 6 | + hasMainFunctionSelector, |
| 7 | +} from './index'; |
4 | 8 |
|
5 | 9 | const buildState = (code: string) => reducer(undefined, editCode(code));
|
6 | 10 |
|
@@ -112,3 +116,30 @@ describe('checking for symbols in assembly output', () => {
|
112 | 116 | );
|
113 | 117 | });
|
114 | 118 | });
|
| 119 | + |
| 120 | +const doHasLlvmIrSymbolsSelector = (code: string) => { |
| 121 | + const state = reducer({ output: { llvmIr: { code, requestsInProgress: 0 } } }, { type: 'test' }); |
| 122 | + return hasLlvmIrSymbolsSelector(state); |
| 123 | +}; |
| 124 | + |
| 125 | +describe('checking for symbols in LLVM IR output', () => { |
| 126 | + test('empty code has no symbols', () => { |
| 127 | + expect(doHasLlvmIrSymbolsSelector('')).toBe(false); |
| 128 | + }); |
| 129 | + |
| 130 | + test('metadata is not a symbol', () => { |
| 131 | + expect( |
| 132 | + doHasLlvmIrSymbolsSelector('source_filename = "playground.d1ee58e2761c15fe-cgu.0"'), |
| 133 | + ).toBe(false); |
| 134 | + expect(doHasLlvmIrSymbolsSelector('!llvm.ident = !{!1}')).toBe(false); |
| 135 | + expect( |
| 136 | + doHasLlvmIrSymbolsSelector('!1 = !{!"rustc version 1.90.0-nightly (3048886e5 2025-07-30)"}'), |
| 137 | + ).toBe(false); |
| 138 | + }); |
| 139 | + |
| 140 | + test('a symbol is a symbol', () => { |
| 141 | + expect( |
| 142 | + doHasLlvmIrSymbolsSelector('define noundef i32 @add(i32 noundef %v) unnamed_addr #0 {'), |
| 143 | + ).toBe(true); |
| 144 | + }); |
| 145 | +}); |
0 commit comments