test bug 545
							parent
							
								
									1fed0cc4a4
								
							
						
					
					
						commit
						5ad6ba07cf
					
				|  | @ -0,0 +1,87 @@ | ||||||
|  | # 用于模拟read方法 | ||||||
|  | class Reader: | ||||||
|  |     @staticmethod | ||||||
|  |     def read(word, value): | ||||||
|  |         print(f"Reading word '{word}' with slider value {value}") | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | is_read = True | ||||||
|  | is_choose = True | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # 模拟获取用户选中的单词 | ||||||
|  | def get_word(): | ||||||
|  |     return "selected word" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # 模拟fillInWord函数的行为 | ||||||
|  | def fill_in_word(): | ||||||
|  |     word = get_word() | ||||||
|  |     if is_read: | ||||||
|  |         Reader.read(word, 5) | ||||||
|  |     if not is_choose: | ||||||
|  |         return | ||||||
|  |         # 模拟selected-words元素 | ||||||
|  |     selected_words = "previous word " | ||||||
|  |     index = selected_words.find(word) | ||||||
|  |     print(f"Current selected words: {selected_words}") | ||||||
|  |     # 假设的localStorage实现 | ||||||
|  |     local_storage = {} | ||||||
|  | 
 | ||||||
|  |     if index == -1: | ||||||
|  |         selected_words += word + " " | ||||||
|  |         local_storage["nowWord"] = selected_words | ||||||
|  |         print(f"Added word to selected words: {selected_words}") | ||||||
|  |     else: | ||||||
|  |         print(f"Word '{word}' is already in selected words.") | ||||||
|  | 
 | ||||||
|  |         # 打印模拟的localStorage内容 | ||||||
|  |     print(f"Local storage: {local_storage}") | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # 假设的slider和rangeValue元素 | ||||||
|  | slider_value = "5×" | ||||||
|  | input_slider_value = 5 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # 模拟slider的oninput事件 | ||||||
|  | def on_slider_input(value): | ||||||
|  |     global slider_value | ||||||
|  |     slider_value = str(value) + '×' | ||||||
|  |     print(f"Slider value changed to: {slider_value}") | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # 模拟按钮点击事件来切换is_read和is_choose的值 | ||||||
|  | def on_read_click(): | ||||||
|  |     global is_read | ||||||
|  |     is_read = not is_read | ||||||
|  |     print(f"Reading is now {'enabled' if is_read else 'disabled'}") | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def on_choose_click(): | ||||||
|  |     global is_choose | ||||||
|  |     is_choose = not is_choose | ||||||
|  |     print(f"Choosing is now {'enabled' if is_choose else 'disabled'}") | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # 假设的功能测试 | ||||||
|  | def run_functional_test(): | ||||||
|  |     print("\nRunning functional test...") | ||||||
|  | 
 | ||||||
|  |     # 模拟用户点击操作,调用fill_in_word函数 | ||||||
|  |     fill_in_word() | ||||||
|  | 
 | ||||||
|  |     # 模拟用户移动滑块,调用on_slider_input函数 | ||||||
|  |     on_slider_input(7) | ||||||
|  | 
 | ||||||
|  |     # 模拟用户点击“Read”按钮,切换is_read状态 | ||||||
|  |     on_read_click() | ||||||
|  |     fill_in_word()  # 再次调用fill_in_word来测试is_read的变化 | ||||||
|  | 
 | ||||||
|  |     # 模拟用户点击“Choose”按钮,切换is_choose状态 | ||||||
|  |     on_choose_click() | ||||||
|  |     fill_in_word()  # 再次调用fill_in_word来测试is_choose的变化 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # 运行功能测试 | ||||||
|  | run_functional_test() | ||||||
		Loading…
	
		Reference in New Issue