sh1k4ku commited on
Commit
a24c4c2
·
verified ·
1 Parent(s): 6b6f0ae

Upload assignment2.html with huggingface_hub

Browse files
Files changed (1) hide show
  1. assignment2.html +68 -7
assignment2.html CHANGED
@@ -97,14 +97,49 @@
97
  .exportbar .sid { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); }
98
  .exportbar .spacer { flex:1; }
99
  .toast { font-size:12px; color:var(--ok); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  </style>
101
  </head>
102
  <body>
103
  <div class="wrap">
104
  <h1>Software Testing — Assignment 2 <span class="pts" style="font-size:13px">[15 marks total]</span></h1>
105
- <p class="muted">Answer all questions below. Q4 has an interactive playground. When you are done, export your answers as JSON at the bottom.</p>
 
 
 
 
 
 
 
 
106
 
107
  <!-- ============ Q1 ============ -->
 
108
  <h2>Q1 &nbsp;Extended Entry Decision Table <span class="pts">[3 pts] · single choice</span></h2>
109
  <p>Test the UNSW Lecture-Theatre Booking system with Decision-Table testing. The system evaluates multi-valued conditions across several inputs to decide whether a booking is Booked, Wait-listed, or Rejected. Rules are checked one by one and the <b>first matching rule</b> applies.</p>
110
 
@@ -142,23 +177,28 @@
142
 
143
  <p class="rules"><b>Notation.</b> <code>!</code> = not; <code>/</code> = alternative; <code>-</code> = a range (e.g. room_size <code>1-3</code>) or a don't-care. Week ranges are inclusive. The Default row applies when inputs are valid but match no prior rule. If a rule is already caught by an earlier rule, its outcome is <code>N/A</code>. Invalid rows use an out-of-domain value such as room_size 0 or week 13. <b>Exactly one table below is correct — select it.</b></p>
144
  <div id="q1opts"></div>
145
-
146
- <!-- ============ Reference function ============ -->
147
- <h2>Reference function <span class="pts">for Q2, Q3, Q4</span></h2>
148
- <pre id="reffn"></pre>
149
 
150
  <!-- ============ Q2 ============ -->
 
 
151
  <h2>Q2 &nbsp;Control-Flow Graph <span class="pts">[2 pts] · single choice</span></h2>
152
  <p>Draw the control-flow graph for <code>binary_search</code>. Below are four candidate CFGs, written as complete DOT graphs and rendered. Exactly one is correct — select it.</p>
153
  <div id="q2opts"></div>
 
154
 
155
  <!-- ============ Q3 ============ -->
 
 
156
  <h2>Q3 &nbsp;Loop-Boundary Test Cases <span class="pts">[2 pts] · fill in the blanks</span></h2>
157
  <p>Develop a test suite achieving loop-boundary coverage (loop runs 0, 1, and 2 times). Fill each circled blank. Recall <code>mid = int(round((top+bott)/2.0))</code>.</p>
158
  <p class="muted">Marking: each loop case = 1 mark; within a case, one wrong blank −0.5, two or more wrong −1.</p>
159
  <pre id="q3block"></pre>
 
160
 
161
  <!-- ============ Q4 ============ -->
 
 
162
  <h2>Q4 &nbsp;Fault-Based Testing: Plant a Bug and Catch It <span class="pts">[6 pts] · playground</span></h2>
163
  <p class="muted">The Q3 suite reaches loop-boundary coverage, but coverage does not guarantee fault detection. This question asks you to demonstrate that gap on the <code>binary_search</code> function above.</p>
164
  <p>(a) Introduce <b>exactly one</b> single-line bug into <code>binary_search</code> so that <b>all three Q3 tests still pass</b> (the bug is invisible to the Q3 suite).
@@ -191,12 +231,15 @@
191
  </div>
192
  <pre id="q4out"><span class="meta">(edit the function, fill the test, then Run check)</span></pre>
193
  </div>
 
194
 
195
  <!-- ============ Q5 ============ -->
 
196
  <h2>Q5 &nbsp;Halstead Programming Effort <span class="pts">[2 pts] · single choice</span></h2>
197
  <p>Calculate the Halstead <b>programming effort</b> for the following code (parentheses are not counted as operators):</p>
198
  <pre id="q5code"></pre>
199
  <div id="q5opts"></div>
 
200
  </div>
201
 
202
  <!-- ============ sticky export bar ============ -->
@@ -235,7 +278,7 @@ const REF_SRC = `def binary_search(key: int, target: list[int]):
235
  else:
236
  top = mid - 1
237
  return found, location`;
238
- document.getElementById("reffn").textContent = REF_SRC;
239
 
240
  // ============ Q1: six decision tables ============
241
  const Q1_COLS = ["rule","room_size","time_slot","week","equipment","staff_role","outcome"];
@@ -541,11 +584,29 @@ function loadSession(){
541
  }
542
  function clearSession(){ localStorage.removeItem(SESSION_KEY); location.reload(); }
543
  // save on the free-text fields too
544
- ["studentId","q4change"].forEach(id => document.getElementById(id).addEventListener("input", saveSession));
545
  [q4target, q4key].forEach(el => el.addEventListener("input", saveSession));
546
  document.getElementById("clearBtn").onclick = clearSession;
547
  // restore once everything above is defined
548
  loadSession();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
549
  </script>
550
  </body>
551
  </html>
 
97
  .exportbar .sid { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); }
98
  .exportbar .spacer { flex:1; }
99
  .toast { font-size:12px; color:var(--ok); }
100
+
101
+ /* ===== Ant-style tabs ===== */
102
+ .tabs { display:flex; gap:2px; border-bottom:1px solid var(--border);
103
+ margin:16px 0 0; overflow-x:auto; position:sticky; top:0;
104
+ background:var(--bg); z-index:5; padding-top:4px; }
105
+ .tabs button { background:transparent; color:var(--muted); border:none;
106
+ border-bottom:2px solid transparent; border-radius:0;
107
+ padding:10px 18px; font-size:14px; font-weight:600; cursor:pointer;
108
+ white-space:nowrap; transition:color .15s, border-color .15s; margin-bottom:-1px; }
109
+ .tabs button:hover:not(:disabled) { background:transparent; color:var(--accent); }
110
+ .tabs button.active { color:var(--accent); border-bottom-color:var(--accent); }
111
+ .tabs button .tpt { display:inline-block; margin-left:7px; font-size:11px; font-weight:600;
112
+ color:var(--muted); background:var(--panel); border-radius:10px; padding:1px 7px; }
113
+ .tabs button.active .tpt { color:#11111b; background:var(--accent); }
114
+ .pane { display:none; padding-top:18px; }
115
+ .pane.active { display:block; animation:tabfade .22s ease; }
116
+ @keyframes tabfade { from{opacity:0; transform:translateY(4px)} to{opacity:1; transform:none} }
117
+ .pane h2:first-child { margin-top:0; border-top:none; padding-top:0; }
118
+ /* collapsible reference function */
119
+ details.refbox { margin:0 0 16px; border:1px solid var(--border); border-radius:8px; background:var(--card); }
120
+ details.refbox > summary { cursor:pointer; padding:9px 13px; font-weight:600; font-size:13px;
121
+ color:var(--accent); list-style:none; user-select:none; }
122
+ details.refbox > summary::-webkit-details-marker { display:none; }
123
+ details.refbox > summary::before { content:"▸ "; }
124
+ details.refbox[open] > summary::before { content:"▾ "; }
125
+ details.refbox pre { margin:0; border:none; border-top:1px solid var(--border); border-radius:0 0 8px 8px; }
126
  </style>
127
  </head>
128
  <body>
129
  <div class="wrap">
130
  <h1>Software Testing — Assignment 2 <span class="pts" style="font-size:13px">[15 marks total]</span></h1>
131
+ <p class="muted">Answer all questions below — one tab per question. Q4 has an interactive playground. Your answers auto-save in this browser; export them as JSON at the bottom when done.</p>
132
+
133
+ <div class="tabs" id="tabbar">
134
+ <button data-tab="q1" class="active">Q1 · Decision Table<span class="tpt">3</span></button>
135
+ <button data-tab="q2">Q2 · Control-Flow Graph<span class="tpt">2</span></button>
136
+ <button data-tab="q3">Q3 · Loop Boundary<span class="tpt">2</span></button>
137
+ <button data-tab="q4">Q4 · Fault-Based<span class="tpt">6</span></button>
138
+ <button data-tab="q5">Q5 · Halstead<span class="tpt">2</span></button>
139
+ </div>
140
 
141
  <!-- ============ Q1 ============ -->
142
+ <section class="pane active" data-tab="q1">
143
  <h2>Q1 &nbsp;Extended Entry Decision Table <span class="pts">[3 pts] · single choice</span></h2>
144
  <p>Test the UNSW Lecture-Theatre Booking system with Decision-Table testing. The system evaluates multi-valued conditions across several inputs to decide whether a booking is Booked, Wait-listed, or Rejected. Rules are checked one by one and the <b>first matching rule</b> applies.</p>
145
 
 
177
 
178
  <p class="rules"><b>Notation.</b> <code>!</code> = not; <code>/</code> = alternative; <code>-</code> = a range (e.g. room_size <code>1-3</code>) or a don't-care. Week ranges are inclusive. The Default row applies when inputs are valid but match no prior rule. If a rule is already caught by an earlier rule, its outcome is <code>N/A</code>. Invalid rows use an out-of-domain value such as room_size 0 or week 13. <b>Exactly one table below is correct — select it.</b></p>
179
  <div id="q1opts"></div>
180
+ </section>
 
 
 
181
 
182
  <!-- ============ Q2 ============ -->
183
+ <section class="pane" data-tab="q2">
184
+ <details class="refbox" open><summary>Reference function — binary_search (used in Q2–Q4)</summary><pre class="reffn"></pre></details>
185
  <h2>Q2 &nbsp;Control-Flow Graph <span class="pts">[2 pts] · single choice</span></h2>
186
  <p>Draw the control-flow graph for <code>binary_search</code>. Below are four candidate CFGs, written as complete DOT graphs and rendered. Exactly one is correct — select it.</p>
187
  <div id="q2opts"></div>
188
+ </section>
189
 
190
  <!-- ============ Q3 ============ -->
191
+ <section class="pane" data-tab="q3">
192
+ <details class="refbox" open><summary>Reference function — binary_search (used in Q2–Q4)</summary><pre class="reffn"></pre></details>
193
  <h2>Q3 &nbsp;Loop-Boundary Test Cases <span class="pts">[2 pts] · fill in the blanks</span></h2>
194
  <p>Develop a test suite achieving loop-boundary coverage (loop runs 0, 1, and 2 times). Fill each circled blank. Recall <code>mid = int(round((top+bott)/2.0))</code>.</p>
195
  <p class="muted">Marking: each loop case = 1 mark; within a case, one wrong blank −0.5, two or more wrong −1.</p>
196
  <pre id="q3block"></pre>
197
+ </section>
198
 
199
  <!-- ============ Q4 ============ -->
200
+ <section class="pane" data-tab="q4">
201
+ <details class="refbox" open><summary>Reference function — binary_search (used in Q2–Q4)</summary><pre class="reffn"></pre></details>
202
  <h2>Q4 &nbsp;Fault-Based Testing: Plant a Bug and Catch It <span class="pts">[6 pts] · playground</span></h2>
203
  <p class="muted">The Q3 suite reaches loop-boundary coverage, but coverage does not guarantee fault detection. This question asks you to demonstrate that gap on the <code>binary_search</code> function above.</p>
204
  <p>(a) Introduce <b>exactly one</b> single-line bug into <code>binary_search</code> so that <b>all three Q3 tests still pass</b> (the bug is invisible to the Q3 suite).
 
231
  </div>
232
  <pre id="q4out"><span class="meta">(edit the function, fill the test, then Run check)</span></pre>
233
  </div>
234
+ </section>
235
 
236
  <!-- ============ Q5 ============ -->
237
+ <section class="pane" data-tab="q5">
238
  <h2>Q5 &nbsp;Halstead Programming Effort <span class="pts">[2 pts] · single choice</span></h2>
239
  <p>Calculate the Halstead <b>programming effort</b> for the following code (parentheses are not counted as operators):</p>
240
  <pre id="q5code"></pre>
241
  <div id="q5opts"></div>
242
+ </section>
243
  </div>
244
 
245
  <!-- ============ sticky export bar ============ -->
 
278
  else:
279
  top = mid - 1
280
  return found, location`;
281
+ document.querySelectorAll(".reffn").forEach(el => el.textContent = REF_SRC);
282
 
283
  // ============ Q1: six decision tables ============
284
  const Q1_COLS = ["rule","room_size","time_slot","week","equipment","staff_role","outcome"];
 
584
  }
585
  function clearSession(){ localStorage.removeItem(SESSION_KEY); location.reload(); }
586
  // save on the free-text fields too
587
+ ["studentId","q4change","q4origout","q4varout"].forEach(id => document.getElementById(id).addEventListener("input", saveSession));
588
  [q4target, q4key].forEach(el => el.addEventListener("input", saveSession));
589
  document.getElementById("clearBtn").onclick = clearSession;
590
  // restore once everything above is defined
591
  loadSession();
592
+
593
+ // ============ tabs (one per question) ============
594
+ (function initTabs(){
595
+ const TAB_KEY = "st_a2_tab";
596
+ const btns = [...document.querySelectorAll("#tabbar button")];
597
+ const panes = [...document.querySelectorAll(".pane")];
598
+ function show(id){
599
+ if (!btns.some(b => b.dataset.tab === id)) id = "q1";
600
+ btns.forEach(b => b.classList.toggle("active", b.dataset.tab === id));
601
+ panes.forEach(p => p.classList.toggle("active", p.dataset.tab === id));
602
+ try { localStorage.setItem(TAB_KEY, id); } catch(_){}
603
+ // CodeMirror needs a refresh when it becomes visible
604
+ if (id === "q4" && typeof editor !== "undefined" && editor) setTimeout(() => editor.refresh(), 0);
605
+ window.scrollTo(0, 0);
606
+ }
607
+ btns.forEach(b => b.onclick = () => show(b.dataset.tab));
608
+ show(localStorage.getItem(TAB_KEY) || "q1");
609
+ })();
610
  </script>
611
  </body>
612
  </html>